Documentation /  Fuzzy Logic /

IntroductionCreating Fuzzy Sets

0.2 New Features in This Release

0.2.1 Introduction

This notebook demonstrates the new features that were added to Fuzzy Logic.

In[1]:=

In[2]:=

The first thing to note is that originally the universal space for fuzzy sets in Fuzzy Logic was defined only on the integers. In the new version, the universal space for fuzzy sets and fuzzy relations is defined with three numbers. The first two numbers specify the start and end of the universal space, and the third argument specifies the increment between elements. This gives the user more flexibility in choosing the universal space.

0.2.2 New Membership Functions

A number of new functions and options were added for creating membership functions. Here is a demonstration of the additions.

Bell-shaped Fuzzy Sets

FuzzyBell[c, w, s, opts] returns a bell-shaped fuzzy set centered at c with crossover points at c - w and c + w with a slope of s / 2w at the crossover points.

In[3]:=

In[4]:=

Sigmoidal Fuzzy Sets

FuzzySigmoid[c, s, opts] returns a sigmoidal fuzzy set where s controls the slope at the crossover point c. A positive slope gives a sigmoidal fuzzy set, which opens to the right, and a negative slope gives a fuzzy set, which opens to the left.

In[5]:=

In[6]:=

In[7]:=

In[8]:=

Double-sided Gaussian Fuzzy Sets

FuzzyTwoGaussian[mu1, sigma1, mu2, sigma2, opts] returns a two-sided Gaussian fuzzy set with centers at mu1 and mu2 and widths of sigma1 and sigma2. Between the two means, the fuzzy set has a membership grade of 1.

In[9]:=

In[10]:=

Digital Fuzzy Sets

DigitalSet[a, b, c, d, (h), opts] returns a digital fuzzy set with the number of membership grades equal to n, where n is set by an option for this function. The universal space and the value of n may be defined using the UniversalSpace and the n option, otherwise the default universal space and default n value will be given. The values of the membership grades increase linearly from a to b, then are equal to the closest possible value of h from b to c, and linearly decrease from c to d. Arguments a, b, c, and d must be in increasing order, and h must be a value between 0 and 1 inclusive. If a value for h is not given, it defaults to 1. In the following example, you can create a fuzzy set with n set to 5. This means you will get a L5 fuzzy set or a fuzzy set with five possible membership grades.

In[11]:=

In[12]:=

ChopValue Option

An option was added to the FuzzyGaussian, FuzzyBell, FuzzySigmoid, FuzzyTwoGaussian, and CreateFuzzySets functions that allows you to specify a Chop value to the function. Any membership grades less than this value are taken as zero. When working with Gaussian type functions, every element will have some membership grade, and it is often the case that many of the elements have very small membership grades. Chopping off these elements allows fuzzy sets to be more compact and allows calculations to be quicker. It also aids in creating fuzzy graphs, which are described later. The following example demonstrates the ChopValue option.

In[13]:=

Out[13]=

In[14]:=

Out[14]=

In[15]:=

In[16]:=

0.2.3 Fuzzy Graph

Another visualization function in Fuzzy Logic is a fuzzy graph. A fuzzy graph describes a mapping between an input linguistic variable and an output linguistic variable. In essence, a fuzzy graph serves as an approximation to a function, which is described in words as a collection of fuzzy if-then rules. A fuzzy graph can be used to give an idea of what a set of fuzzy rules look like.

Demonstration

In[17]:=

In[18]:=

In[19]:=

In[20]:=

In[21]:=

In[22]:=

In[23]:=

In[24]:=

From the FuzzyGraph, you can see that the single-input/single-output fuzzy system described by Rules1 will produce a curve that is somewhat parabolic.

0.2.4 Defuzzifications

In[25]:=

Smallest of Max (Defuzzification)

SmallestOfMax[A] returns the smallest of maximum defuzzification of fuzzy set A. This function also has a ShowGraph option for visualizing the defuzzification.

In[26]:=

Largest of Max (Defuzzification)

LargestOfMax[A] returns the largest of maximum defuzzification of fuzzy set A. This function also has a ShowGraph option for visualizing the defuzzification.

In[27]:=

Bisector of Area (Defuzzification)

BisectorOfArea[A] returns the bisector of area defuzzification of fuzzy set A. This function also has a ShowGraph option for visualizing the defuzzification.

In[28]:=

0.2.5 Additional Operators

Fuzzy Cardinality

FuzzyCardinality[A] returns the fuzzy cardinality of fuzzy set A.

In[29]:=

Out[29]=

Core

This function was included in the original Fuzzy Logic package, but it was named Nucleus.

Core[A] returns a list of all elements of fuzzy set A with a membership grade equal to 1.

In[30]:=

Out[30]=

Subsethood

Subsethood[A, B] returns the degree of subsethood of fuzzy set/fuzzy relation A in fuzzy set/fuzzy relation B. The value returned will be between 0 and 1, with values closer to 1 indicating that the second fuzzy set/fuzzy relation is closer to being a subset of the first fuzzy set/fuzzy relation.

In[31]:=

Out[31]=

In[32]:=

Out[32]=

Hamming Distance

HammingDistance[A, B] returns the Hamming distance from fuzzy set/fuzzy relation A to fuzzy set/fuzzy relation B.

In[33]:=

Out[33]=

Level Set

LevelSet[A] returns the set of all levels alpha that represent distinct alpha cuts of a fuzzy set/relation A.

In[34]:=

Out[34]=

0.2.6 New Intersections and Unions

Yu Type Union and Intersection

Yu[l] is an additional value for the Type option for the union and intersection operations. The parameter l must be greater than -1.

In[35]:=

In[36]:=

Weber Type Union and Intersection

Weber[l] is an additional new value for the Type option for the union and intersection operations. The parameter l must be greater than -1.

In[37]:=

In[38]:=

0.2.7 Alpha Cuts for Fuzzy Relations

One of the most important concepts of fuzzy sets/fuzzy relations is the concept of an alpha level set and its variant, a strong alpha level set. Alpha level set of fuzzy set/fuzzy relation is the crisp set that contains all the elements of universal space whose membership grades in set/relation are greater than or equal to the specified value of alpha. Strong alpha level set of fuzzy set/fuzzy relation is the crisp set that contains all the elements of universal space whose membership grades in set/relation are greater than the specified value of alpha. The set of all alpha levels that represent distinct alpha cuts of a fuzzy set/fuzzy relation is called a level set of set/relation.

In[39]:=

In[40]:=

In[41]:=

In[42]:=

In[43]:=

In[44]:=

Out[44]=

In[45]:=

Out[45]=

In[46]:=

Out[46]=

0.2.8 Fuzzy Relation Equations

The notion of fuzzy relation equations is associated with the concept of the max-min form of composition of binary relations.

Solve for a Fuzzy Relation

In the following example, you will determine a fuzzy relation Relat1 given the system's input A and output B.

In[47]:=

Out[47]=

In[48]:=

Out[48]=

In[49]:=

Out[49]=

Solve for a Fuzzy Set

You can view fuzzy relation as a fuzzy system. Then given its output you can determine the input. In the following example, apply the FindFuzzySet function to determine the input NewA for fuzzy relation Rel2 and output B.

In[50]:=

Out[50]=

In[51]:=

Out[51]=

0.2.9 Random Fuzzy Sets and Fuzzy Relations

These functions are used to create a random fuzzy set or fuzzy relation. This type of operation might be valuable to test new functions.

Random Fuzzy Set

RandomFuzzySet[{a, b}] creates a random fuzzy set with universal space from a to b. By default, this function will create a random trapezoidal fuzzy set. The option Type can be used to create a Gaussian, Triangular, or Complete random fuzzy set. In addition, there is an option called Normal that produces a normal random fuzzy set, when set to True.

Just as with normal random numbers you can seed the random number generator to produce the same random fuzzy numbers each time. To test the RandomFuzzySet function, try reevaluating the function a number of times with different parameters.

In[52]:=

In[53]:=

In[54]:=

In[55]:=

In[56]:=

In[57]:=

In[58]:=

In[59]:=

Random Fuzzy Relation

RandomFuzzySet[{{a1 , b1}, {a2, b2}}] creates a random fuzzy relation with universal space of {{a1, b1}, {a2, b2}}. By default, this function will create a random trapezoidal fuzzy relation. The option Type can be used to create a Complete random fuzzy relation. In addition, there is an option called Normal that produces a normal random fuzzy relation, when set to True.

In[60]:=

In[61]:=

0.2.10 Fuzzy Inferencing

Rule-based Inference

RuleBasedInference[{{A1, ... ,An}, ... , {S1, ... ,Sp}}, {Y1, ... ,Yk}, {Ax, ... , Sx, Yx}, {a, ... ,s}, opts] returns a fuzzy set that is the result of performing rule based inference for multiple-input/single-output systems where {{A1, ... , An}, ... , {S1, ... , Sp}} represent linguistic input variables, {Y1, ... ,Yk} is the linguistic output variable, rules are given in a list like {Ax, ... , Sx, Yx}, and the crisp values for the inputs are given in a list {a, ... ,s}. The values for the option Type are Mamdani, Model, and Scaled.

For an example, see the 1_08_FuzzyInference.nb notebook.

0.2.11 Fuzzy Arithmetic

Fuzzy Multiplication and Division

FuzzyMultiply[{a1, b1, c1, d1}, {a2, b2, c2, d2}] returns the product of the fuzzy numbers represented by the two lists. The fuzzy product is returned as an unevaluated FuzzyTrapezoid. To evaluate the FuzzyTrapezoid, use the ReleaseHold function.

In[62]:=

In[63]:=

Out[63]=

In the following, you can plot an approximate result of the fuzzy product. Notice the use of the ReleaseHold command.

In[64]:=

FuzzyDivide[{a1, b1, c1, d1}, {a2, b2, c2, d2}] returns the division of the fuzzy numbers represented by the two lists. The fuzzy division is returned as an unevaluated FuzzyTrapezoid. To evaluate the FuzzyTrapezoid, use the ReleaseHold function.

In[65]:=

Out[65]=

You can plot the approximate result of the fuzzy division. Notice the use of the ReleaseHold command.

In[66]:=

0.2.12 Fuzzy Clustering

Fuzzy C-Means Clustering

FCMCluster[data, partmat, mu, epsilon] returns a list of cluster centers, a partition matrix indicating the degree to which each data point belongs to a particular cluster center, and a list containing the progression of cluster centers found during the run. The arguments to the function are the data set (data), an initial partition matrix (partmat), a value determining the degree of fuzziness of the clustering (mu), and a value which determines when the algorithm will terminate (epsilon). This function runs recursively until the terminating criteria is met. While running, the function prints a value which indicates the accuracy of the fuzzy clustering. When this value is less than the parameter epsilon, the function terminates. The parameter mu is called the exponential weight and controls the degree of fuzziness of the clusters. As mu approaches 1, the fuzzy clusters become crisp clusters, where each data point belongs to only one cluster. As mu approaches infinity, the clusters become completely fuzzy, and each point will belong to each cluster to the same degree (1/c) regardless of the data. Studies have been done on selecting the value for mu, and it appears that the best choice for mu is usually in the interval [1.5, 2.5], where the midpoint, mu = 2, is probably the most commonly used value for mu.

To demonstrate the FCM clustering algorithm, you can create a data set which consists of four group of data.

In[67]:=

In[68]:=

In[69]:=

Out[69]=

The last line shows coordinates for four centers. The clustering function also provides the degrees to which each data point belongs to each cluster and the cluster center progression. Because there are problems showing the cluster centers for data of higher dimensions, the ShowCenters function only works for 2D clustering. If you want to see the 3D cluster centers with the original data, you could do the following:

In[70]:=

The clustering function should work for data of any dimension, but it is hard to visualize the results for higher order data.

IntroductionCreating Fuzzy Sets


Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information