Fuzzy Logic

## New Feature Documentation

### 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.

### 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.

#### 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.

#### 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.

#### 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.

#### 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.

### 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

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

#### 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.

#### 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.

#### 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.

#### Fuzzy Cardinality

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

#### 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.

#### 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.

#### Hamming Distance

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

#### Level Set

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

### 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.

#### 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.

### 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.

### 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.

#### 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.

### 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.

#### 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.

### 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.

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

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.

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

### 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.

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.

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