Documentation /  Fuzzy Logic /  Manual /

New Features in This ReleaseCreating Fuzzy Relations

1.1 Creating Fuzzy Sets

1.1.1 Introduction

Fuzzy Logic provides a number of convenient ways to create fuzzy sets. This chapter demonstrates these functions and the options associated with each function.

This loads the package.

In[1]:=

1.1.2 Basic Objects

Fuzzy set object.

FuzzySet is one of the fundamental objects used in the package. Here is its full form:

    FuzzySet[{{u1, X(u1)}, ... ,{un, X(un)}}, UniversalSpaceRule{a, b, c}]

where u1, ... , un are elements of the universal space and X(u1), ... , X(un) are the grades of membership of the elements in a fuzzy set.

Option for FuzzySet.

In[2]:=

Out[2]=

By default the universal space is set to 0, 1, 2, ..., 20. When creating fuzzy sets, if an explicit universal space is not given, this default value will be used. Universal spaces for fuzzy sets and fuzzy relations are 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 discrete elements.

A built-in Mathematica function gives the list of default options assigned to a symbol.

In[3]:=

Out[3]=

You can change the default value for UniversalSpace globally.

In[4]:=

Out[4]=

Fuzzy sets can be created manually by entering a list of element and membership grade pairs surrounded by the FuzzySet head. Here is a simple example.

In[5]:=

Out[5]=

When studying fuzzy sets, it is often instructive to look at fuzzy sets graphically. A description of the graphing functions and how to use them appears later in Chapter 1.5 Fuzzy Set Visualization, but you can use one of the graphing functions here to look at your newly created fuzzy set FS1.

In[6]:=

1.1.3 Functions for Creating Fuzzy Sets

This way of creating fuzzy set objects might be quite tedious. Fuzzy Logic provides a number of functions to create special types of fuzzy sets.

Functions for creating fuzzy sets.

We will now show a number of examples on how to create fuzzy sets.

FuzzyTrapezoid[a, b, c, d, h, opts] returns a fuzzy set with membership grades that linearly increase from 0 to h in the range a to b, are equal to h in the range b to c, and linearly decrease from h to 0 in the range 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 specified, the function will use h = 1. The universal space may be explicitly defined using the UniversalSpace option, or if a universal space is not specified, the default universal space is used.

This example shows how to create a trapezoidal fuzzy set with height 0.7. Note that universal space for this fuzzy set is explicitly set.

In[7]:=

Out[7]=

After evaluating this command, we receive a fuzzy set containing a list of the element and membership grade pairs followed by a universal space.

Here we use the function FuzzyPlot to look at our newly created fuzzy set.

In[8]:=

The following is another example of creating a trapezoidal fuzzy set. This time we give the vertices of the trapezoid and allow the function to provide a default setting for the height. Another thing to note about this example is that the second and third parameters for specifying the trapezoid are the same. This technique is used to create triangular fuzzy sets.

In[9]:=

Out[9]=

In[10]:=

FuzzyGaussian[mu, sigma, opts] returns a new fuzzy set whose membership grades represent a normalized Gaussian function with a mean of mu and a width of sigma. In this example, we create a Gaussian fuzzy set centered at 17 with a width of 6. Note that we chose to specify our own universal space instead of accepting the default setting.

In[11]:=

Out[11]=

In[12]:=

Note that in the example, the membership grades for some of the elements are very small. The option ChopValue works with the FuzzyGaussian, FuzzyTwoGaussian, FuzzyBell, and FuzzySigmoid functions. It allows you to specify a value for which all membership grades less than that value are set to zero. We demonstrate this option in the following example.

In[13]:=

Out[13]=

Notice that all the membership grades that were less than 0.01 from the previous example are now set to zero.

In[14]:=

FuzzyBell[c, w, s, opts] returns a bell-shaped fuzzy set centered at c with crossover points at c ± w with a slope s / (2 w) at the crossover points. Here is an example of creating a bell-shaped fuzzy set centered at 50 with crossover points at 50 ± 20 and a slope of 4 / (2 * 20) at the crossover points.

In[15]:=

In[16]:=

The function FuzzyTwoGaussian[mu1, sigma1, mu2, sigma2, opts] creates 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. Here we create a two-sided Gaussian fuzzy set with centers at 40 and 50 and widths of 8 and 25, respectively. Between the two means, the fuzzy set has a membership grade of 1.

In[17]:=

In[18]:=

FuzzySigmoid[c, s, opts] creates a sigmoidal fuzzy set where s controls the slope at the crossover point c. Here we create a sigmoidal fuzzy set with the slope at the crossover point 50. Because the slope of 0.2 is positive, the fuzzy set opens to the right.

In[19]:=

Here we create a sigmoidal fuzzy set with the slope at the crossover point 50. Because now the slope of -0.2 is negative, the fuzzy set opens to the left.

In[20]:=

In[21]:=

We can create a fuzzy set by specifying a membership function. The function CreateFuzzySet[func, {a, b, c}] returns a fuzzy set with membership grades defined by func in the range a to b, inclusive. If no range is given, the function is applied to all of the elements in the universal space. Note that the function must return values between 0 and 1 over the range provided to create a valid fuzzy set. This is an example of creating a fuzzy set using a piecewise function. The first definition defines the function to use to create the fuzzy set.

In[22]:=

In[23]:=

In[24]:=

Sometimes we need to create a collection of FuzzySet objects that span a given universal space. CreateFuzzySets[num, opts] returns a list of num overlapping fuzzy sets that span the universal space. The fuzzy sets can be either Triangular or Gaussian. The Type option specifies the shape of the new fuzzy sets, and Triangular membership functions are the default setting.

In[25]:=

Out[25]=

Option for CreateFuzzySets.

In this example, we divide the universal space into six triangular fuzzy sets. We use an extra option with the FuzzyPlot command to show a continuous representation of the fuzzy sets.

In[26]:=

In[27]:=

As a final example of fuzzy set creation, we create a set of seven Gaussian fuzzy sets. When specifying the Gaussian type of fuzzy set, we should provide a width with the Type option. If no width is specified, a width of 1 is used. The option ChopValue works with the CreateFuzzySets function for a specified width. It allows you to specify a value for which all membership grades less than that value are set to zero.

In[28]:=

In[29]:=

Note in the previous example, we assigned variable names to each of the new fuzzy sets. This enables us to reference each individual fuzzy set. This technique is important for the fuzzy inferencing commands that we will talk about later in Chapter 1.8 Fuzzy Inferencing. To show that we indeed can access the individual fuzzy sets, we graph a couple of the fuzzy sets here.

In[30]:=

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, which produces a normal Triangular random fuzzy set, when set to True.

Options for RandomFuzzySet.

Just as with normal random numbers we 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[31]:=

In[32]:=

In[33]:=

In[34]:=

In[35]:=

In[36]:=

In[37]:=

In[38]:=

You can use a built-in function SetOptions to restore the default setting for the FuzzySet object.

In[39]:=

Out[39]

New Features in This ReleaseCreating Fuzzy Relations


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