Fuzzy Lectures
Fuzzy Lectures
Fuzziness is probability in disguise. I can design a controller with probability that could
do the same thing that you could do with fuzzy logic.
-Professor Myron Tribus, on hearing of the fuzzy-logic control of the Sendai subway
system IEEE Institute, may 1988.
www.sxc.hu
The definition of the apple and apple core sets are too strictly defined when looking at
the process of eating an apple. The area between the two sets is not clearly defined since
1
the object cannot belong to the set of apples and apple cores because, by definition, an
apple core is NOT an apple. The sets defining apples and apple cores need to be redefined
as fuzzy sets.
A fuzzy set allows for its members to have degrees of membership. If the value of 1 is
assigned to objects entirely within the set and a 0 is assigned to objects outside of the set,
then any object partially in the set will have a value between 0 and 1. The number
assigned to the object is called its degree of membership in the set. So an apple with one
bite out of it may have a degree of membership of 0.9 in the set of apples. This does not
mean that it has to have a degree of membership of 0.1 in the set of apple cores though.
However as the apple is eaten it looses its membership in the fuzzy set of apples and
gains membership in the fuzzy set of apple cores.
Application areas
The function shown above describes the membership of the 'tall' set, you are either in it or
you are not in it. This sharp edged membership functions works nicely for binary
operations and mathematics, but it does not work as nicely in describing the real world.
The membership function makes no distinction between somebody who is 6'1" and
someone who is 7'1", they are both simply tall. Clearly there is a significant difference
between the two heights. The other side of this lack of distinction is the difference
between a 5'11" and 6' man. This is only a difference of one inch, however this
membership function just says one is tall and the other is not tall.
The fuzzy set approach to the set of tall men provides a much better representation of the
tallness of a person. The set, shown below, is defined by a continuously inclining
function.
The membership function defines the fuzzy set for the possible values underneath of it on
the horizontal axis. The vertical axis, on a scale of 0 to 1, provides the membership value
of the height in the fuzzy set. So for the two people shown above the first person has a
membership of 0.3 and so is not very tall. The second person has a membership of 0.95
and so he is definitely tall. He does not, however, belong to the set of tall men in the way
that bivalent sets work; he has a high degree of membership in the fuzzy set of tall men.
This definition of a fuzzy set is like a superset of the definition of a set in the ordinary
sense of the term. The grades of membership of 0 and 1 correspond to the two
possibilities of truth and false in an ordinary set. The ordinary boolean operators that are
used to combine sets will no longer apply; we know that 1 AND 1 is 1, but what is 0.7
AND 0.3? This will be covered in the fuzzy operations section.
Membership functions for fuzzy sets can be defined in any number of ways as long as
they follow the rules of the definition of a fuzzy set. The Shape of the membership
function used defines the fuzzy set and so the decision on which type to use is dependant
on the purpose. The membership function choice is the subjective aspect of fuzzy logic, it
allows the desired values to be interpereted appropriatly. The most common membership
functions are shown below:
www.mathworks.com
The things of the universe are not sliced off from one another with a hatchet, neither the
hot from the cold nor the cold from the hot.
-Anaxagoras-
x AND y
x OR y
NOT x
The truth table above works fine for bivalent logic but fuzzy logic does not have a finite
set of possibilities for each input; this makes for an infinitely large truth table. The
operators need to be defined as functions for all possible fuzzy values, that is, all real
numbers from 0 to 1 inclusive. Fuzzy logic is actually a superset of bivalent logic since it
includes the bivalent options (0,1) as well as all reals in between, so a generalized form of
these operators will be usefull. The generalized form for these three operators are:
x AND y
min(x,y)
x OR y
max(x,y)
NOT x
1-x
Using these definitions they can be applied to all of the bivalent combinations above as
well as some fuzzy number combinations. The truth table for this can be seen below:
x
min(x,y)
max(x,y)
1-x
0.2 0.5
0.2
0.5
0.8
0.7 0.2
0.2
0.7
0.3
0.6 0.6
0.6
0.6
0.4
Contents
6
Fuzzy logic
Fuzzy logic is a form of multi-valued logic derived from fuzzy set theory to deal with
reasoning that is approximate rather than precise. Just as in fuzzy set theory the set
membership values can range (inclusively) between 0 and 1, in fuzzy logic the degree of
truth of a statement can range between 0 and 1 and is not constrained to the two truth
values {true, false} as in classic predicate logic.[1] And when linguistic variables are used,
these degrees may be managed by specific functions, as discussed below.
Fuzzy set theory was first introduced in 1965 by Lotfi Zadeh at the University of
California, Berkeley and fuzzy logic was derived from it for use in applications.[2] It has
been applied to diverse fields from control theory to artificial intelligence, yet still
remains controversial among most statisticians who prefer probabilistic logic and some
control engineers who prefer traditional two valued logic.
probabilistic setting would first define a scalar variable for the fullness of the glass, and
second, conditional distributions describing the probability that someone would call the
glass full given a specific fullness level. Note that the conditioning can be achieved by
having a specific observer that randomly selects the label for the glass, a distribution over
deterministic observers, or both. While fuzzy logic avoids talking about randomness in
this context, this simplification at the same time obscures what is exactly meant by the
statement the 'glass is 0.3 full'.
In this image, cold, warm, and hot are functions mapping a temperature scale. A point on
that scale has three "truth values" one for each of the three functions. The vertical line
in the image represents a particular temperature that the three arrows (truth values) gauge.
Since the red arrow points to zero, this temperature may be interpreted as "not hot". The
orange arrow (pointing at 0.2) may describe it as "slightly warm" and the blue arrow
(pointing at 0.8) "fairly cold".
like fuzzy conditions, fuzzy comparators, fuzzy constants, fuzzy constraints, fuzzy
thresholds, linguistic labels and so on.
Other examples
IF male IS true AND height >= 1.8 THEN is_tall IS true; is_short IS false
The fuzzy rules do not make the sharp distinction between tall and short, that is
not so realistic:
10
11
12
; 0 <= t <= 10
1:
2:
3:
4:
if
if
if
if
X
X
X
X
is
is
is
is
Notice that instead of assigning a single value to the output variable Z, each
rule assigns an entire fuzzy subset (low or high).
Notes:
1. In this example, low(t)+high(t)=1.0 for all t. This is not required, but it
is fairly common.
2. The value of t at which low(t) is maximum is the same as the value of
t at which high(t) is minimum, and vice-versa. This is also not
required, but fairly common.
3. The same membership functions are used for all variables. This isn't
required, and is also not common.
Solved Example
Let: X = 0.0 and Y = 3.2
Find the fuzzy membership function of the output variable Z, and hence find
its crisp value.
To solve this example, the following four steps should be done in sequence.
Step 1: Fuzzification
In the fuzzification subprocess, the membership functions defined on the
input variables are applied to their actual values, to determine the degree of
truth for each rule premise. If a rule's premise has a nonzero degree of truth
(if the rule applies at all...) then the rule is said to [fire].
Degree of
Membership
1.00
0.0
0.68
0.32
Note that to compute L(X) and L(Y) we substitute in the equation {low(t)
= 1 - t / 10} using values of {t} equals 0.0 and 3.2, respectively. Similarly, to
compute H(X) and H(Y) we substitute in the equation { high(t) = t / 10}
using the same values of {t}. Sometimes it is easier to have the membership
functions in a tabulated form, and you just look-up the given tables.
14
Step 2: Inference
In the inference subprocess, the truth value for the premise of each rule is
computed, and applied to the conclusion part of each rule. This results in one
fuzzy subset to be assigned to each output variable for each rule. The
table below shows that we get H(Z) = 0.68 from rule 1, and L(Z) = 0.32
from rule 2.
Activated Rules
ANDing of Antecedents
L(Z)
H(Z)
min(1.00, 0.68)
0.68
min(1.00, 0.32)
0.32
Using the MIN inferencing method, the components of (Z) obtained from
both rule 1 and rule 2 are shown in Fig. 2. Both rule 3 and rule 4 are
not fired because their premises has a zero degree of truth, and hence
they will not add any component to (Z). The following are the
equations for the four components of the output membership
function (Z).
(Z) {from rule1}
(Z) {from rule2}
6.8 }
(Z) {from rule3}
(Z) {from rule4}
Fig. 2: Membership function of the output Z using rule #1, #2 with MIN
inference.
For the same conditions (rule 1: x = 0.0 and y = 3.2), PRODUCT
inferencing will assign Z the fuzzy subset defined by the membership
function:
(Z) {from rule1} = 0.68 * high(Z); and = 0.068 * Z
16
Step 3- Composition
In the composition subprocess, all of the fuzzy subsets assigned to each
output variable are combined together to form a single fuzzy subset for each
output variable.
There are two common composition rules: MAX composition and SUM
composition.
In MAX composition, the combined output fuzzy subset is
constructed by taking the pointwise maximum over all of the fuzzy
subsets assigned to the output variable by the inference rule.
In SUM composition the combined output fuzzy subset is constructed
by taking the pointwise sum over all of the fuzzy subsets assigned to
the output variable by the inference rule.
Note that the SUM composition can result in truth values greater than one!
For this reason, SUM composition is only used when it will be followed by a
defuzzification method, such as the CENTROID method, that doesn't have a
problem with this odd case.
MAX composition would result in the following fuzzy subset (Fig.3).
(Z) = { 0.32,
Z / 10,
0.68,
if Z <= 3.2
if 3.2 <= Z <= 6.8
if Z >= 6.8 }
Alternative Solution
An alternative solution for steps 2 (Inference) and 3 (Composition) is to use
PRODUCT inference with MAX composition. This solution is shown in Fig.
4 and Fig. 5, respectively. These diagrams are obtained as follows:
PRODUCT inferencing would assign the following four fuzzy subsets
to Z:
(Z) {from rule1}
(Z) {from rule2}
(Z) {from rule3}
(Z) {from rule4}
= 0.068 * Z
= 0.32 - 0.032 * Z
= 0.0
= 0.0
18
19
Step 4- Defuzzification
Sometimes it is useful to just examine the fuzzy subsets that are the result of
the composition process, but more often, this fuzzy value needs to be
converted to a single number - a crisp value. This is what the defuzzification
subprocess does.
There are many defuzzification methods and there is a short paper that
compared roughly thirty defuzzification methods. Two of the more common
techniques are the CENTROID and MAXIMUM methods.
In the CENTROID method, the crisp value of the output Z is obtained
by computing the centroid of the area under the composed
membership curve. Approximately the centroid can be computed from
the following formula, where (x) represents the values on the
horizontal X-axis, and represents the corresponding values on the
vertical Y-axis.
C = { x . (x) } / (x)
In the MAXIMUM method, one of the variable values at which the
fuzzy subset has its maximum truth value is chosen as the crisp value
for the output variable. There are several variations of the
MAXIMUM method that differ only in what they do when there is
more than one variable value at which this maximum truth value
occurs. One of these, the AVERAGE-OF-MAXIMA method, returns
the average of the variable values at which the maximum truth value
occurs.
For example, go back to our previous examples. The following table shows
the output crisp value as computed using four different methods (refer to
Fig. 3 and Fig. 5). It is clear that the centroid methods give decent values for
both inference methods.
{Inference / Composition}
MIN / MAX
PRODUCT / SUM
CENTROID
Z = 5.88
Z = 5.624
20
Average of Maxima
Z = (6.8+10)/2 = 8.4
Z = 10
Input Variables
Room Size: V
Ambient Temperature: T
Output Variable
21
8
9
The fuzzy sets low, medium, and high are defined next for each one of the input
and output variables.
22
1) Room Size: V
23
2) Ambient Temperature: T
24
Example Problem
In the above-mentioned fuzzy controller, the room size is 45 cubic meters and the
ambient temperature is 30o.
1. Use the MIN/MAX method to find the fuzzy membership function for the shutter
angle (F).
2. Use the center of gravity method to find the crisp value of F.
Solution
The solution steps are as follows:
1. Fuzzification of the input variables.
2. Inference from the fuzzy knowledge base, based on the degree of membership in
the considered fuzzy sets for all input variables. This inference determines which
rules in the fuzzy knowledge base will be activated, and hence for each activated
rule there will be a corresponding degree of membership for the output variable(s)
in every considered fuzzy set.
3. Composition of the resultant membership function for the output variable(s).
4. Defuzzification of the resultant membership function to obtain a crisp value of
the output variable.
Step 1: Fuzzification
Degree of
Membership
Room size, V
0.25
0.75
0.0
Temperature, T
0.0
0.25
0.75
To get the degrees of membership for the input variable V draw a vertical line at the value
of this variable (here it is at V=45), and find its intersection with the three fuzzy
membership functions (low, medium, and high). Repeat the same thing for the other input
variable T.
Alternatively if you have a table giving numerical values of the fuzzy membership
functions, you can directly read the required value () from the table, or interpolate its
value if it is not explicitly given in the table. For example, the fuzzy membership
functions for the temperature T are shown next.
To get a value for L(13) from this table, we only have a value of 0.5 at T=12 and 0.25 at
T=14. By interpolation (assume straight line between the two points) we can calculate the
value at T=13 to be (0.5+0.25)/2 = 0.375. Therefore L(13) = 0.375
25
low(T)
1
1
1
1
1
0.75
0.5
0.25
0
0
0
0
0
0
0
0
0
0
0
0
0
medium(T)
0
0
0
0
0
0.25
0.5
0.75
1
1
1
1
1
0.75
0.5
0.25
0
0
0
0
0
high(T)
0
0
0
0
0
0
0
0
0
0
0
0
0
0.25
0.5
0.75
1
1
1
1
1
Step 2: Inference
Activated Rules
ANDing of Antecedents
L(F)
M(F)
H(F)
min(0.25, 0.25)
0.25
min(0.25, 0.75)
0.25
min(0.75,0.25)
0.25
min(0.75, 0.75)
0.75
26
Step 3: Composition
Here we shall use the MIN inference with MAX composition method. After completing
the inference process, we proceed to compose the membership function of the shutter
angle (F). From step 2 we find that:
1. The maximum value of M(F) is 0.25, then we draw the first component of the
required membership function (F) by clamping the function M(F) at level 0.25.
2. The maximum value of L(F) is 0.75, then we draw the second component of the
required membership function (F) by clamping the function L(F) at level 0.75.
3. The required membership function of the shutter angle (F) is obtained by adding
the above-mentioned two components.
27
Step 4: Defuzzification
The above diagram shows the resulting fuzzy membership function for the shutter angle
after inference and composition. As mentioned before, there are many methods for
obtaining a crisp value for the output. Two methods are considered here.
The average of maxima method
In this method the maximum values of the composed output (shutter angle)
membership function are recorded, and their average is computed to be the crisp
value. In the above diagram, the maximum values range from 70 o to 90o and
hence their average is 80o.
The center of gravity method (centroid)
The crisp value of the output (shutter angle) is obtained by computing the
centroid of the area under the composed membership curve. Approximately the
centroid can be computed from the following formula, where (x) represents the
values on the horizontal X-axis, and represents the corresponding values on the
vertical Y-axis. The computed value of the centroid is 65o, which is the crisp value
for the shutter angle.
C = { x . (x) } / (x)
28