Fuzzy Logic Products
-----
 /
Fuzzy Logic
*What's New in Version 2?
<New Feature Documentation
*Features
*Sample Images
*Contents
*Q&A
*Examples
*Who's It For?
*Download Product
Manual
*Buy Online
*Technical FAQs
*Documentation
*For More Information
*Higher Education Solutions
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

New Feature Documentation

download notebookDownload as a Mathematica notebook.


New Definition of Universal Space

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.

<< FuzzyLogic

SetOptions[FuzzySet, 
UniversalSpace -> {0, 100, 1}] ;


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 and with a slope of s / 2w at the crossover points.

FS1 = FuzzyBell[50, 20, 4] ;

FuzzyPlot[FS1, PlotJoined -> True] ;

[Graphics:HTMLFiles/version2_5.gif]


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.

FS2 = FuzzySigmoid[50, .2] ;

FuzzyPlot[FS2, PlotJoined -> True] ;

[Graphics:HTMLFiles/version2_8.gif]

FS3 = FuzzySigmoid[50, -.2] ;

FuzzyPlot[FS3, PlotJoined -> True] ;

[Graphics:HTMLFiles/version2_11.gif]

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.

FS4 = FuzzyTwoGaussian[40, 8, 50, 25] ;

FuzzyPlot[FS4, PlotJoined -> True] ;

[Graphics:HTMLFiles/version2_14.gif]

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 UniversalSpace and the n option; otherwise the default universal space and the default n value are 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 an L5 fuzzy set or a fuzzy set with five possible membership grades.

D1 = DigitalSet[1, 20, 40, 78, Levels -> 5] ;

FuzzyPlot[D1, Crisp -> True] ;

[Graphics:HTMLFiles/version2_17.gif]

ChopValue Option

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

FS5 = FuzzyGaussian     [20, 5, 
UniversalSpace      -> {0, 40, 1}]

FuzzySet[{{0, 1.125351747192592`*^-7}, {1, 
5.355347802793108`*^-7}, {2, 2.3525752000097718`*^-6}, {3, 9.540162873079237`*^-6}, 
{4, 0.000035712849641635225`}, {5, 
0.0001234098040866796`}, {6, 0.000393669040655078`}, {7, 0.0011592291739045907`}, 
{8, 0.0031511115984444392`}, {9, 
0.007907054051593435`}, {10, 0.018315638888734182`}, {11, 0.03916389509898707`}, 
{12, 0.07730474044329971`}, {13, 
0.14085842092104486`}, {14, 0.2369277586821217`}, {15, 0.36787944117144233`}, 
{16, 0.5272924240430482`}, {17, 
0.6976763260710308`}, {18, 0.8521437889662112`}, {19, 0.9607894391523232`}, 
{20, 1.`}, {21, 0.9607894391523232`}, {22, 
0.8521437889662112`}, {23, 0.6976763260710308`}, {24, 0.5272924240430482`}, 
{25, 0.36787944117144233`}, {26, 
0.2369277586821217`}, {27, 0.14085842092104486`}, {28, 0.07730474044329971`}, 
{29, 0.03916389509898707`}, {30, 
0.018315638888734182`}, {31, 0.007907054051593435`}, {32, 0.0031511115984444392`}, 
{33, 0.0011592291739045907`}, {34, 
0.000393669040655078`}, {35, 0.0001234098040866796`}, {36, 0.000035712849641635225`}, 
{37, 9.540162873079237`*^-6}, 
{38, 2.3525752000097718`*^-6}, {39, 5.355347802793108`*^-7}, 
{40, 1.125351747192592`*^-7}}, UniversalSpace -> {0, 
40, 1}]

FS6 = FuzzyGaussian     [20, 5, 
UniversalSpace -> {0, 40, 1}, ChopValue -> .01]

FuzzySet[{{10, 0.018315638888734182`}, {11, 
0.03916389509898707`}, {12, 0.07730474044329971`}, {13, 0.14085842092104486`}, 
{14, 0.2369277586821217`}, {15, 
0.36787944117144233`}, {16, 0.5272924240430482`}, {17, 0.6976763260710308`}, 
{18, 0.8521437889662112`}, {19, 
0.9607894391523232`}, {20, 1.`}, {21, 0.9607894391523232`}, {22, 0.8521437889662112`}, 
{23, 0.6976763260710308`}, {24, 
0.5272924240430482`}, {25, 0.36787944117144233`}, {26, 0.2369277586821217`}, 
{27, 0.14085842092104486`}, {28, 
0.07730474044329971`}, {29, 0.03916389509898707`}, {30, 0.018315638888734182`}}, 
UniversalSpace -> {0, 40, 1}]

Var2 = {NB, NM, NS, ZO, PS, PM, PB} = <br /> 
     CreateFuzzySets     [7, 
Type -> Gaussian   [4, ChopValue 
-> 0.001 ], <br />        UniversalSpace -> 
{0, 38, 0.5}] ;

FuzzyPlot    [Var2, PlotJoined 
    -> True ] ;

[Graphics:HTMLFiles/version2_24.gif]

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 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 looks like.

Demonstration

SetOptions[FuzzySet, 
UniversalSpace -> {1, 11, 1}] ;

Input1 = {Tiny, VerySmall, 
Small, Medium, Big, VeryBig, 
Huge} = {FuzzyTrapezoid[1, 1, 1, 3], FuzzyTrapezoid[1, 2, 2, 4], FuzzyTrapezoid[2, 4, 4, 6], 
FuzzyTrapezoid[4, 6, 6, 
8], FuzzyTrapezoid[6, 8, 8, 10], FuzzyTrapezoid[8, 10, 10, 11], FuzzyTrapezoid[9, 11, 11, 11]} ;

FuzzyPlot[Input1, 
PlotJoined -> True] ;

[Graphics:HTMLFiles/version2_28.gif]

SetOptions[FuzzySet, 
UniversalSpace -> {2, 25, 1}] ;

Output1 = {VeryLow, Low, Middle, High} = 
{FuzzyTrapezoid[2, 4, 4, 6], FuzzyTrapezoid[4, 5, 5, 8], FuzzyGaussian[9, 3, 
ChopValue -> .001], FuzzyGaussian[20, 
3, ChopValue -> .001]} ;

FuzzyPlot[Output1, 
PlotJoined -> True] ;

[Graphics:HTMLFiles/version2_32.gif]

Rules1 = 
{{Tiny, High}, {VerySmall, Middle}, {Small, 
Low}, {Medium, VeryLow}, {Big, Low}, {VeryBig, Middle}, {Huge, High}} ;

FuzzyGraph[Rules1] ;

[Graphics:HTMLFiles/version2_35.gif]

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


Defuzzifications

MF1 = FuzzyTrapezoid[1, 6, 13, 17, UniversalSpace -> 
{0, 20}] ;

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.

SmallestOfMax[MF1, 
ShowGraph -> True, PlotJoined -> 
True] ;

Smallest of max is 6.`

[Graphics:HTMLFiles/version2_39.gif]

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.

LargestOfMax[MF1, 
ShowGraph -> True, PlotJoined -> 
True] ;

Largest of max is 13.`

[Graphics:HTMLFiles/version2_42.gif]

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.

BisectorOfArea[MF1, 
ShowGraph -> True, PlotJoined 
-> True] ;

Bisector of area is 9.`

[Graphics:HTMLFiles/version2_45.gif]

Additional Operators

Fuzzy Cardinality

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

FuzzyCardinality[MF1]

{{15, 1/5}, {14, 1/4}, 
{13, 2/5}, {12, 1/2}, {11, 3/5},
{10, 3/4}, {9, 4/5}, {8, 1}}

Core

The function Core was included in the original version of Fuzzy Logic, but it was named Nucleus.

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

Core[FS4]

{40, 41, 42, 43, 44, 45, 46, 
47, 48, 49, 50}

Subsethood

Subsethood[A, B] returns the degree of subsethood of fuzzy set/fuzzy relation A in fuzzy set/fuzzy relation B. The value returned is 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.

Subsethood[FS1, FS2]

0.5093556728268867`

Subsethood[FS2, FS1]

0.4139212223595349`

Hamming Distance

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

HammingDistance[FS1, FS2]

49.732120724970265`

Level Set

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

LevelSet[FS1]

{0.00065493078456103`, 0.0007697273319525108`,
0.0009076443370994577`, 0.0010739657558160637`, 0.0012753315066968212`, 
0.0015201245436999506`,
0.0018189797372572304`, 0.002185456418354002`, 0.0026369319635966147`, 
0.0031957954400961422`,
0.0038910505836575876`, 0.004760479752244069`, 0.0058535798275806536`, 
0.007235563907879275`, 0.008992837637916461`,
0.011240516628798644`, 0.014132762581791842`, 0.017876987382551945`, 
0.022753297866633316`, 0.029140877833621966`,
0.03755317588381986`, 0.048683416619404896`, 0.06346027066201429`, 
0.08310891316612122`, 0.10920240820445293`,
0.14366857315728437`, 0.1886857617060043`, 0.2463647123619463`, 
0.31810776168273736`, 0.4036399534477936`, 0.5`,
0.6011709253956037`, 0.6990722982038854`, 0.7858604683671828`, 
0.8563314268427156`, 0.9089976004549426`,
0.9454941441245656`, 0.9691195095219717`, 0.9834812908813503`, 
0.99169613771978`, 0.9961089494163424`,
0.9983213101988873`, 0.999345069215439`, 0.9997748631589487`, 
0.9999343943043897`, 0.9999847414437646`,
0.9999974400065536`, 0.9999997437110032`, 0.9999999900000001`, 
0.9999999999609376`, 1.`}


New Intersections and Unions

Yu-Type Union and Intersection

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

YuInt = Intersection[FS1, FS2, Type -> Yu[2]] ;

FuzzyPlot[FS1, FS2, YuInt, PlotJoined -> True] ;

[Graphics:HTMLFiles/version2_60.gif]

Weber-Type Union and Intersection

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

WeUn = Union[FS1, FS2, Type -> Weber[0.5]] ;

FuzzyPlot[FS1, FS2, WeUn, PlotJoined -> True] ;

[Graphics:HTMLFiles/version2_63.gif]


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. An alpha-level set of a fuzzy set/fuzzy relation is the crisp set that contains all the elements of universal space whose membership grades in the set/relation are greater than or equal to the specified value of alpha. A strong alpha-level set of the fuzzy set/fuzzy relation is the crisp set that contains all the elements of universal space whose membership grades in the 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 the set/relation.

SetOptions[FuzzySet, UniversalSpace -> {0, 20, 1}]
;

FS1 = FuzzyTrapezoid[1, 8, 12, 17] ;

FS2 = FuzzyBell[5, 3, 2] ;

rel1 = 
SetsToRelation[Min, FS1, FS2] ;

FuzzySurfacePlot[rel1] ;

[Graphics:HTMLFiles/version2_69.gif]

AlphaLevelSet[rel1, .2]

{{3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}, {3, 7},
{3, 8}, {3, 9}, {4, 1}, {4, 2}, {4, 3}, {4, 4}, {4, 5}, {4, 6}, {4, 7}, {4, 8}, {4, 9}, 
{5, 1}, {5, 2}, {5, 3}, {5,
4}, {5, 5}, {5, 6}, {5, 7}, {5, 8}, {5, 9}, {6, 1}, {6, 2}, {6, 3}, {6, 4}, {6, 5}, {6, 6}, 
{6, 7}, {6, 8}, {6, 9},
{7, 1}, {7, 2}, {7, 3}, {7, 4}, {7, 5}, {7, 6}, {7, 7}, {7, 8}, {7, 9}, {8, 1}, {8, 2}, 
{8, 3}, {8, 4}, {8, 5}, {8,
6}, {8, 7}, {8, 8}, {8, 9}, {9, 1}, {9, 2}, {9, 3}, {9, 4}, {9, 5}, {9, 6}, {9, 7}, {9, 8}, 
{9, 9}, {10, 1}, {10,
2}, {10, 3}, {10, 4}, {10, 5}, {10, 6}, {10, 7}, {10, 8}, {10, 9}, {11, 1}, {11, 2}, 
{11, 3}, {11, 4}, {11, 5}, {11,
6}, {11, 7}, {11, 8}, {11, 9}, {12, 1}, {12, 2}, {12, 3}, {12, 4}, {12, 5}, {12, 6}, 
{12, 7}, {12, 8}, {12, 9}, {13,
1}, {13, 2}, {13, 3}, {13, 4}, {13, 5}, {13, 6}, {13, 7}, {13, 8}, {13, 9}, {14, 1}, 
{14, 2}, {14, 3}, {14, 4}, {14,
5}, {14, 6}, {14, 7}, {14, 8}, {14, 9}, {15, 1}, {15, 2}, {15, 3}, {15, 4}, {15, 5}, 
{15, 6}, {15, 7}, {15, 8}, {15,
9}, {16, 1}, {16, 2}, {16, 3}, {16, 4}, {16, 5}, {16, 6}, {16, 7}, {16, 8}, {16, 9}}

StrongAlphaLevelSet[rel1, .2]

{{3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}, {3, 7},
{3, 8}, {3, 9}, {4, 1}, {4, 2}, {4, 3}, {4, 4}, {4, 5}, {4, 6}, {4, 7}, {4, 8}, {4, 9}, 
{5, 1}, {5, 2}, {5, 3}, {5,
4}, {5, 5}, {5, 6}, {5, 7}, {5, 8}, {5, 9}, {6, 1}, {6, 2}, {6, 3}, {6, 4}, {6, 5}, {6, 6}, 
{6, 7}, {6, 8}, {6, 9},
{7, 1}, {7, 2}, {7, 3}, {7, 4}, {7, 5}, {7, 6}, {7, 7}, {7, 8}, {7, 9}, {8, 1}, {8, 2}, 
{8, 3}, {8, 4}, {8, 5}, {8,
6}, {8, 7}, {8, 8}, {8, 9}, {9, 1}, {9, 2}, {9, 3}, {9, 4}, {9, 5}, {9, 6}, {9, 7}, {9, 8}, 
{9, 9}, {10, 1}, {10,
2}, {10, 3}, {10, 4}, {10, 5}, {10, 6}, {10, 7}, {10, 8}, {10, 9}, {11, 1}, {11, 2}, 
{11, 3}, {11, 4}, {11, 5}, {11,
6}, {11, 7}, {11, 8}, {11, 9}, {12, 1}, {12, 2}, {12, 3}, {12, 4}, {12, 5}, {12, 6}, 
{12, 7}, {12, 8}, {12, 9}, {13,
1}, {13, 2}, {13, 3}, {13, 4}, {13, 5}, {13, 6}, {13, 7}, {13, 8}, {13, 9}, {14, 1}, 
{14, 2}, {14, 3}, {14, 4}, {14,
5}, {14, 6}, {14, 7}, {14, 8}, {14, 9}, {15, 1}, {15, 2}, {15, 3}, {15, 4}, {15, 5}, 
{15, 6}, {15, 7}, {15, 8}, {15,
9}}

LevelSet[rel1]

{0.001597444089456869`, 
0.0021040600566277893`,
0.002828014803435514`, 0.0038910505836575876`, 0.005501969841054204`, 
0.008034917170915585`, 0.012195121951219513`,
0.019391908067991383`, 0.03263497179693795`, 0.058823529411764705`, 
0.11473087818696884`, 1/7, 1/5,
0.2403560830860534`, 2/7, 2/5, 3/7, 0.5`, 4/7, 3/5, 5/7, 4/5, 0.8350515463917526`, 
6/7, 0.9878048780487805`, 1.`}


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 determine a fuzzy relation Relat1 given the system's input A and output B.

A = FuzzySet[{{1, .2}, {2, .8}, {3, 1}}, UniversalSpace
-> {1, 3, 1}]

FuzzySet[{{1, 0.2`}, {2, 0.8`}, {3, 1}}, UniversalSpace
-> {1, 3, 1}]

B = FuzzySet[{{1, .5}, {2, .8}, {3, .6}},
UniversalSpace -> {1, 3, 1}]

FuzzySet[{{1, 0.5`}, {2, 0.8`}, {3, 0.6`}}, UniversalSpace
-> {1, 3, 1}]

Relat1 = FindFuzzyRelation[A, B]

FuzzyRelation[{{{1, 1}, 1}, {{1, 2}, 1}, {{1, 3}, 1}, {{2,
1}, 0.5`}, {{2, 2}, 1}, {{2, 3}, 0.6`}, {{3, 1}, 0.5`}, {{3, 2}, 0.8`}, {{3, 3}, 0.6`}}, 
UniversalSpace -> {{1, 3, 1}, {1, 3, 1}}]


Solve for a Fuzzy Set

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

Rel2 = FromMembershipMatrix[{{.7, 1, .4}, {.5, .9, .6},
{.2, .6, .3}}, {{1, 3}, {1, 3}}]

FuzzyRelation[{{{1, 1}, 0.7`}, {{1, 2}, 1}, {{1, 3},
0.4`}, {{2, 1}, 0.5`}, {{2, 2}, 0.9`}, {{2, 3}, 0.6`}, {{3, 1}, 0.2`}, {{3, 2}, 0.6`}, {{3, 3}, 0.3`}},
UniversalSpace -> {{1, 3, 1}, {1, 3, 1}}]

NewA = FindFuzzySet[Rel2, B]

FuzzySet[{{1, 0.5`}, {2, 0.8`}, {3, 1}}, UniversalSpace
-> {1, 3, 1}]


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 creates 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 function RandomFuzzySet, try reevaluating the function a number of times with different parameters.

FS1 = RandomFuzzySet[{0, 30}] ;

FuzzyPlot[FS1] ;

[Graphics:HTMLFiles/version2_88.gif]

FS2 = RandomFuzzySet[{0, 30}, Type -> Gaussian] ;

FuzzyPlot[FS2] ;

[Graphics:HTMLFiles/version2_91.gif]

FS3 = RandomFuzzySet[{0, 30}, Type -> Triangular,
Normal -> True] ;

FuzzyPlot[FS3] ;

[Graphics:HTMLFiles/version2_94.gif]

FS3 = RandomFuzzySet[{0, 30}, Type -> Complete] ;

FuzzyPlot[FS3] ;

[Graphics:HTMLFiles/version2_97.gif]


Random Fuzzy Relation

RandomFuzzySet[{{a1, b1}, {a2, b2}}] creates a random fuzzy relation with a universal space of {{a1, b1}, {a2, b2}}. By default, this function creates 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.

fr1 = RandomFuzzyRelation[{{0, 10}, {0, 15}}] ;

FuzzySurfacePlot[fr1] ;

[Graphics:HTMLFiles/version2_100.gif]

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.


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 FuzzyTrapezoid, use the function ReleaseHold.

SetOptions[FuzzySet, UniversalSpace -> {-40, 15,
1}] ;

Multi1 = FuzzyMultiply[{-9, 2, 2, 3}, {1, 2, 2, 4},
UniversalSpace -> {-40, 15, 1}]

FuzzyTrapezoid[-36, 4, 4, 12, UniversalSpace -> {-40,
15, 1}]

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

FuzzyPlot[ReleaseHold[Multi1]] ;

[Graphics:HTMLFiles/version2_105.gif]

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 FuzzyTrapezoid, use the function ReleaseHold.

Div1 = FuzzyDivide[{-9, 2, 2, 3}, {1, 2, 2, 4},
UniversalSpace -> {-10, 10}]

FuzzyTrapezoid[-9, 1, 1, 3, UniversalSpace -> {-10,
10, 1}]

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

FuzzyPlot[ReleaseHold[Div1]] ;

[Graphics:HTMLFiles/version2_109.gif]

Fuzzy Clustering

Fuzzy C-Means (FCM) 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 that determines when the algorithm terminates (epsilon). This function runs recursively until the terminating criteria are met. While running, the function prints a value that 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 belongs 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 that consists of four groups of data.

TrainData3D = {{1, 2, 3}, {2, 2, 2}, {2, 1, 3}, {3, 3,
2}, {4, 5, 4}, {4, 4, 5}, {5, 5, 4}, {7, 7, 7}, {9, 9, 7}, {8, 8, 8}, {9, 8, 9}, {10, 9, 7}, 
{9, 9, 8}, {10, 1, 1},
{8, 2, 1}, {8, 2, 2}} ;

g1 = Show[Graphics3D[Map[{Hue[0], PointSize[.02],
Point[#]} &, TrainData3D]], Axes -> True] ;

[Graphics:HTMLFiles/version2_112.gif]

Res1a = FCMCluster[TrainData3D,
InitializeU[TrainData3D, 4], 2, .01]

0.8595964614753882`

0.39046927043781954`

0.580970579819335`

0.33459014925966335`

0.15914624581375436`

0.027168447729792433`

0.00819178506930418`

{{{8.80256793540836`, 
8.456249085628325`,
7.724962765182466`}, {8.60842170078829`, 1.7031458174897414`, 
1.3492656845982085`}, {1.9192176111496386`,
1.9161036099437463`, 2.5390130104770208`}, {4.366150459139378`, 
4.702406104157879`, 4.316568363372673`}},
{{0.007904540974564922`, 0.0024548272632447894`, 0.007879737439312693`, 
0.02004008597342445`,
0.0063803400588609595`, 0.01934894009709973`, 0.013808726701058621`, 
0.6755724805302588`, 0.9657322517647037`,
0.95730394931007`, 0.9362609524648138`, 0.9243642692107851`, 
0.9851995809021478`, 0.022543565253051602`,
0.0063742301570240256`, 0.010977987054205314`}, {0.0162630621518874`, 
0.006708023273594329`, 0.020870520719133572`,
0.05745495343904012`, 0.007970399479830559`, 0.02445185164294412`, 
0.017991220128965004`, 0.06364937073411661`,
0.009735793269360263`, 0.01054333073290246`, 0.01783133758096286`, 
0.02392931067414145`, 0.004140313562225994`,
0.9029699694255855`, 0.9617312867092983`, 0.9350379070793334`}, 
{0.9273632706299341`, 0.9746133250531696`,
0.9247365017229828`, 0.7321820173969066`, 0.019525248474879145`, 
0.06614179149558512`, 0.026316220975175306`,
0.05565657242373926`, 0.006910177068439342`, 0.008556858079698125`, 
0.01360393797362594`, 0.015397392932071865`,
0.0031059858793259787`, 0.03364895083186152`, 0.014181896385723288`, 
0.02211958000249782`}, {0.04846912624361362`,
0.016223824409991226`, 0.04651324011857087`, 0.19032294319062878`, 
0.9661240119864294`, 0.8900574167643711`,
0.9418838321948011`, 0.2051215763118854`, 0.017621777897496572`, 
0.02359586187732924`, 0.03230377198059741`, 0.03630902718300169`, 
0.007554119656300253`, 0.040837514489501396`, 0.017712586747954312`, 
0.031864525863963405`}}, {{{7.153063870376806`, 6.305363441316803`, 
5.849487143205868`}, {7.938767337439063`, 4.6463621855077335`, 
4.822615752922692`}, {5.699220146235808`, 4.365454978137112`, 
3.862121332912683`}, {5.304854540215992`, 4.482568817906961`, 
4.57857577322712`}}, {{8.04289680453429`, 7.543418501282312`, 
7.078213790420685`}, {7.769014490024291`, 4.663071219462589`, 
4.286114139983722`}, {4.777922503615974`, 3.2926297200963024`, 
3.135739619016896`}, {4.394537332114551`, 3.8376127404979634`, 
3.7727898072572725`}}, {{8.559704342839305`, 8.223247549853506`, 
7.61299645261957`}, {7.923312962551385`, 2.625035149452373`, 
2.345085538238881`}, {4.024775846627968`, 2.4238446347371685`, 
2.486596428143113`}, {3.9232795500920927`, 3.584402284052031`, 
3.5495778165777354`}}, {{8.733411501656565`, 8.397400293101512`, 
7.703313893157148`}, {8.327635880423138`, 1.8327152020900577`, 
1.5154923908456228`}, {2.508984777819112`, 2.2949669914493356`, 
2.535799541479069`}, {3.7624079075750836`, 3.9793951207558456`, 
3.924434229944321`}}, {{8.77123770365296`, 8.429840438958937`, 
7.714212742952917`}, {8.53990702099636`, 1.7399689052593545`, 
1.3812318809860085`}, {2.057669329939419`, 2.035807920458396`, 
2.483769149081641`}, {4.236739107224269`, 4.575989219083187`, 
4.318324325027511`}}, {{8.795120147272012`, 8.450278661230973`, 
7.723149774430022`}, {8.596276161238446`, 1.7095299691614094`, 
1.3541591098439143`}, {1.944064981453656`, 1.9393317940835644`, 
2.5206975424348967`}, {4.347037447455397`, 4.685279114003056`, 
4.327325008283301`}}, {{8.80256793540836`, 8.456249085628325`, 
7.724962765182466`}, {8.60842170078829`, 1.7031458174897414`, 
1.3492656845982085`}, {1.9192176111496386`, 1.9161036099437463`, 
2.5390130104770208`}, {4.366150459139378`, 4.702406104157879`, 
4.316568363372673`}}}}

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

g2 = Show[g1, Graphics3D[Map[{Hue[0.7],
PointSize[.03], Point[#]} &, Res1a[[1]]]]] ;

[Graphics:HTMLFiles/version2_123.gif]

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

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