[go: up one dir, main page]

0% found this document useful (0 votes)
43 views77 pages

Lecture Basic of Fuzzy Logic

The document provides an overview of fuzzy logic, which is a mathematical framework for dealing with uncertainty and vagueness by allowing degrees of truth rather than binary true/false values. It introduces concepts such as fuzzy sets, membership functions, and their applications in real-world scenarios like washing machines and autonomous vehicles. Fuzzy logic contrasts with traditional Boolean logic by accommodating a spectrum of membership values, reflecting more human-like reasoning in decision-making processes.

Uploaded by

julfikar.sarker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views77 pages

Lecture Basic of Fuzzy Logic

The document provides an overview of fuzzy logic, which is a mathematical framework for dealing with uncertainty and vagueness by allowing degrees of truth rather than binary true/false values. It introduces concepts such as fuzzy sets, membership functions, and their applications in real-world scenarios like washing machines and autonomous vehicles. Fuzzy logic contrasts with traditional Boolean logic by accommodating a spectrum of membership values, reflecting more human-like reasoning in decision-making processes.

Uploaded by

julfikar.sarker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 77

Fuzzy Logic

Outline

Fuzzy expert systems: Fuzzy logic


 Introduction, or what is fuzzy thinking?
 Fuzzy sets
 Linguistic variables and hedges
 Operations of fuzzy sets
 Fuzzy rules
 Summary
Introduction, or what is fuzzy thinking?
 Experts rely on common sense when they solve
problems.
 How can we represent expert knowledge that
uses vague and ambiguous terms in a computer?
 Fuzzy logic is not logic that is fuzzy, but logic that
is used to describe fuzziness. Fuzzy logic is the
theory of fuzzy sets, sets that calibrate vagueness.
 Fuzzy logic is based on the idea that all things
admit of degrees. Temperature, height, speed,
distance, beauty – all come on a sliding scale. The
motor is running really hot. Tom is a very tall guy.
 Fuzzy Logic is particularly good at
handling uncertainty, vagueness and
imprecision.
 This is especially useful where a
problem can be described linguistically
(using words) or, as with neural
networks, where there is data and you
are looking for relationships or patterns
within that data.
 Fuzzy Logic uses imprecision to provide
robust, tractable solutions to problems.
 Fuzzy logic relies on the concept of a
fuzzy set.
 Boolean logic uses sharp distinctions. It forces us
to draw lines between members of a class and non-
members. For instance, we may say, Tom is tall
because his height is 181 cm. If we drew a line at
180 cm, we would find that David, who is 179 cm,
is small. Is David really a small man or we have
just drawn an arbitrary line in the sand?
 Fuzzy logic reflects how people think. It attempts
to model our sense of words, our decision making
and our common sense. As a result, it is leading to
new, more human, intelligent systems.
 Fuzzy, or multi-valued logic was introduced in the
1930s by Jan Lukasiewicz , a Polish philosopher.
While classical logic operates with only two values
1 (true) and 0 (false), Lukasiewicz introduced logic
that extended the range of truth values to all real
numbers in the interval between 0 and 1. He used a
number in this interval to represent the possibility
that a given statement was true or false. For
example, the possibility that a man 181 cm tall is
really tall might be set to a value of 0.86. It is
likely that the man is tall. This work led to an
inexact reasoning technique often called possibility
theory.
 In 1965 Lotfi Zadeh, published his famous paper
“Fuzzy sets”. Zadeh extended the work on
possibility theory into a formal system of
mathematical logic, and introduced a new concept
for applying natural language terms. This new
logic for representing and manipulating fuzzy terms
was called fuzzy logic, and Zadeh became the
Master of fuzzy logic.
 Why fuzzy?
As Zadeh said, the term is concrete, immediate and
descriptive; we all know what it means.
However, many people in the West
were repelled by the word fuzzy ,
because
 Why it is usually used in a negative sense.
logic?
Fuzziness rests on fuzzy set theory, and fuzzy logic
is just a small part of that theory.
Fuzzy logic is a set of mathematical principles
for knowledge representation based on degrees
of membership.

Unlike two-valued Boolean logic, fuzzy logic is


multi-valued. It deals with degrees of
membership and degrees of truth. Fuzzy logic
uses the continuum of logical values between 0
(completely false) and 1 (completely true). Instead
of just black and white, it employs the spectrum of
colours, accepting that things can be partly true and
partly false at the same time.
Range of logical values in Boolean and fuzzy logic

0 01 0 1 1 0 0 0.2 0.4 0.6 0.8 1 1


(a) Boolean Logic. (b) Multi-valued Logic.
What does it offer?
 The first applications of fuzzy theory were primarily
industrial, such as process control for cement kilns.
 Since then, the applications of Fuzzy Logic
technology have virtually exploded, affecting things
we use everyday.
Take for example, the fuzzy washing machine .
 A load of clothes in it and press start, and the
machine begins to turn, automatically choosing the
best cycle. The fuzzy microwave, Place chili,
potatoes, or etc in a fuzzy microwave and push
single button, and it cooks for the right time at the
proper temperature.
 The fuzzy car, maneuvers itself by following simple
verbal instructions from its driver. It can even stop
itself when there is an obstacle immediately ahead
using sensors.

07/08/25 11
Fuzzy sets
 The concept of a set is fundamental to
mathematics.
 However, our own language is also the supreme
expression of sets. For example, car indicates the set
of cars. When we say a car , we mean one out of the
set of cars.
Fuzzy sets is fully defined by
its membership functions.
Membership function is a
function in [0,1] that
represents the degree of
belonging.
Let’s start with a
simple example
 Ask yourself how tall you are?
 Would you classify yourself as a tall
person?
 What is the limit that determines tall
and short people?
 Let’s collect some figures from you
1

0
height
short tall
Let’s consider the first
example
(How tall/short we are?)
1 1

0 5ft 11ins 7ft height 0 5ft 11ins 7ft height

A crisp way of modelling A crisp version of short


tallness
Let’s consider the first
example
(How tall/short we are?)
1
tall

very tall
quite tall
0 5ft 11ins 7ft height

crisp definitions for tallness


Definition in a Fuzzy Set
(How tall/short we are?)

0
height
Definition in a Fuzzy Set
(How tall/short we are?)

0 5ft 11ins 7 ft
height

A possible fuzzy set tall


Definition in a Fuzzy Set
(How tall/short we are?)

0 5ft 11ins 7 ft
height

A possible fuzzy set short


Definition in a Fuzzy Set
(How tall/short we are?)

short tall
1
0.75
0.40

0 5ft 11ins 7 ft
height

Membership functions that


represent tallness and short
Some maths!
Formal definitions of a
fuzzy set
 For any fuzzy set, (let’s say) A, the function
µA represents the membership function for
which µA(x) indicates the degree of
membership that x, of the universal set X,
belongs to set A and is, usually, expressed
as a number between 0 and 1
µA(x) : X [0,1]
 Fuzzy sets can be either discrete or
continuous
 The classical example in fuzzy sets is tall men.
The elements of the fuzzy set “tall men” are all
men, but their degrees of membership depend on
their height.
Crisp and fuzzy sets of “tall men”
Degree of
Crisp Sets
Membership
1.0

0.8

0.6

0.4

0.2

0.0
150 160 170 180 190 200 210
Height, cm
Degree of
Fuzzy Sets
Membership
1.0

0.8

0.6

0.4

0.2

0.0
150 160 170 180 190 200 210
Height, cm
 The x-axis represents the universe of discourse –
the range of all possible values applicable to a
chosen variable. In our case, the variable is the man
height. According to this representation, the
universe of men’s heights consists of all tall men.
 The y-axis represents the membership value of the
fuzzy set. In our case, the fuzzy set of “tall men”
maps height values into corresponding membership
values.
A fuzzy set is a set with fuzzy boundaries.
 Let X be the universe of discourse and its elements
be denoted as x. In the classical set theory, crisp
set A of X is defined as function fA(x) called the
characteristic function of A
1, if x  A
fA(x): X {0, 1}, where f A ( x ) 
0, if x  A

This set maps universe X to a set of two elements.


For any element x of universe X, characteristic
function fA(x) is equal to 1 if x is an element of set
A, and is equal to 0 if x is not an element of A.
 In the fuzzy theory, fuzzy set A of universe X is
defined by function A(x) called the membership
function of set A
A(x): X  [0, 1], where A(x) = 1 if x is totally in A;
A (x) = 0 if x is not in A;
0 < A (x) < 1 if x is partly in A.
This set allows a continuum of possible choices.
For any element x of universe X, membership
function A(x) equals the degree to which x is an
element of set A. This degree, a value between 0
and 1, represents the degree of membership, also
called membership value, of element x in set A.
How to represent a fuzzy set in a
computer?
 First, we determine the membership functions. In
our “tall men” example, we can obtain fuzzy sets of
tall, short and average men.
 The universe of discourse – the men’s heights –
consists of three sets: short, average and tall men.
As you will see, a man who is 184 cm tall is a
member of the average men set with a degree of
membership of 0.1, and at the same time, he is also
a member of the tall men set with a degree of 0.4.
Crisp and fuzzy sets of short, average and tall men
Degreeof CrispSets
Membership
1.0
0.8 Short Average Tall

0.6
0.4
0.2

0.0
150 160 170 180 190 200 210
Height, cm
Degreeof Fuzzy Sets
Membership
1.0

0.8
0.6 Short Average Tall

0.4
0.2

0.0
150 160 170 180 190 200 210
 The notation for fuzzy sets: for the member,
x, of a discrete set with membership µ, we use
the notation µ/x . In other words, x is a member
of the set to degree µ.
 Discrete sets are defined as:

A = µ1 /x1+µ2/x2+…..+µn/xn

 or (in a more compact form)

x1 ,x2 , ….. xn : members of the set A


µ1, µ2,…..µn : x1 , x2 ….. xn ’s degree of
membership.
 A continuous fuzzy set A can be
defined as:

µ
Example:
Discrete and
Continuous
fuzzy sets to
represent the set
of numbers
“close to 1”

numbers
Probability Vs Fuzzy
Logic
● Probabilities on a finite universal set must add
to 1 while there is no such requirement for
membership grades.
● Fuzzy set theory differs from conventional set
theory as it allows each element of a given set
to belong to that set to some degree.
● In contrast to classical set theory each element
either fully belongs to the set or is completely
excluded from the set.
● In other words, classical set theory represents a
special case of the more general fuzzy set
theory.
● Elements in a fuzzy set X posses membership
values between 0 and 1.The degree to which an
element belongs to given set is called Grade of
Membership.
Probability Vs Fuzzy
Logic
● Represent “Helen is old” using probability theory
and fuzzy set. Assume that Helen’s age is 75.
Probability approach:
● We may assign the statement “Helen is old” the
truth value of 0.95. The interpretation is that
there is 95% chance of Helen is old
Fuzzy approach:
● The statement could be translated into fuzzy set
terminology as follows:
● Helen is a member of the set of old people.
● It could be expressed in symbolic notation of
fuzzy set as OLD(Helen) = 0.95 i.e., Helen’s
degree of membership within the set of old
people = 0.95
Distinction in two views

Important distinction between fuzzy


systems and probability.
● Although these two statements seem similar
but they actually carry different meanings.
● First view: There are 5% chances that Helen
may not old
● Second view: There is no chance of Helen
being young and she is more or less old.
− Here µOLD is a membership function operation on the
fuzzy set of old people (denoted OLD) which return a
value between 0 and 1.
 Membership function µOLD for the fuzzy set OLD is
represented as
• Membership function for crisp (conventional) set
older than 50 years is represented as:
Various Types of Membership Functions
• S-shaped function
• Z-shaped function
• Triangular Membership Function
• Trapezoidal Membership Function
• Gaussian Distribution Function
• Pi function
• Vicinity function
S-shaped function

0, for x a
2[(x-a) / (c-a)]2 , for a x b
S(x, a, b, c) = 1- 2[(x-c) / (c-a)]2 , for b < x c
1, for x c
Graphical Representation
of S-Shaped Function

a b c
Figure S-shaped Membership Function
Z-Shaped Function

● It represents an asymmetrical polynomial curve


open to the left.
● Z-membership function may be defined as follows:

1, for x a
1- 2[(x-a) / (c-a)]2, for a x b
Z(x, a, b, c) = 2[(x-c) / (c-a)]2, for b < x c
0, for x c
Graphical Representation

a b c
Figure Z membership function
Triangular membership
functions
0, if x < a
(x – a) / (b- a), if a ≤ x ≤ b
F(x, a, b, c) =
(c – x) / (c – b), if b ≤ x ≤

0, if c < x
Cont…
1.2

1
Membership Values

0.8

0.6

0.4

0.2

a b c
0
0 20 40 60 80 100

Figure Triangular Function


• Trapezoidal membership function

0, if x < a
(x – a) / (b- a), if a ≤ x ≤ b
F(x, a, b, c, d) = 1, if b < x < c
(d – x) / (d – c), if c ≤ x ≤ d
0, if d < x
Trapezoidal membership
function
0, if x < a
(x – a) / (b- a), if a ≤ x ≤ b
F(x, a, b, c, d) = 1, if b < x < c
(d – x) / (d – c), if c ≤ x ≤ d
0, if d < x
Cont…
Gaussian membership
function  ( x b) 2

 ( x, a, b) e 2a2

The graph given in Fig. 10.6 is for parameters a = 0.22, b = 0.78

a b
Figure Gaussian Membership Function
Pi Function

● Pi-shaped curve is a spline-based curve which is named so


because of its shape.
● This membership function is evaluated at four points namely a,
b, c, and d.
● The parameters a and d locate the ‘feet’ of the curve, while b
and c locate its ‘shoulders’. In the graph given in Fig. 10.14, a
= 2, b = 4, c = 5, and d = 9.

a b c d
Figure Pi-shaped Membership Function
Vicinity function

● To represent the statement “x is close to x0, where x0 is


any fixed value of x”, vicinity function using S function as
follows can be used:

S(x, a – b, x – b/2, a ), for x a


V(x, b, a ) =
1 - S(x, a, x + b/2, a + b), for x a

● This is also called π function. Here ‘b’ is called bandwidth.


● Total width of the function between two zero points is
equal to ‘2b’.
a
Figure Vicinity Function
Basic Operations
● For reshaping the memebership functions,
following three operations can be used.
− Dilation (DIL) : It increases the degree of
membership of all members by spreading out the
curve. For example, DIL(OLD) = more or less OLD. Its
membership function is defined as: (µA (x)) 0.5
− Concentration (CON): It decreases the degree of
membership of all members. For example
CONS(OLD) = very OLD. Its membership function is
defined as: (µA (x)) 2
− Normalization (NORM) : It discriminates all
membership degree in the same order unless
maximum value of any member is 1. Its membership
function is defined as: µA(x) / max (µA(x)), x  X
− A fuzzy set is called normalized when at least one of
its elements attains the maximum possible
membership grade i.e., 1.
Methods for Determining
Membership Functions
● Membership functions can be designed by analyzing
the problem in hand.
● There are many possible forms of membership
functions.
● Most of the actual fuzzy control operations are
drawn from a small set of different curves.
● The methods for determining membership functions
may be broadly classified into the following
categories which are explained briefly as follows:
− Trail and Error Basis
− Subjective evaluation and elicitation
− Converted frequencies or probabilities
− Physical measurement
− Learning and adaptation
Representation of crisp and fuzzy subsets
 (x)
X FuzzySubsetA
1

0
Crisp SubsetA Fuzziness x

Typical functions that can be used to represent a fuzzy


set are sigmoid, gaussian and pi. However, these
functions increase the time of computation. Therefore,
in practice, most applications use linear fit functions.
Linguistic variables and hedges
 At the root of fuzzy set theory lies the idea of
linguistic variables.
 A linguistic variable is a fuzzy variable. For
example, the statement “John is tall” implies that
the linguistic variable John takes the linguistic value
tall.
In fuzzy expert systems, linguistic variables are used
in fuzzy rules. For example:
IF wind is strong
THEN sailing is good

IF project_duration is long
THEN completion_risk is high

IF speed is slow
THEN stopping_distance is short
 The range of possible values of a linguistic variable
represents the universe of discourse of that variable.
For example, the universe of discourse of the
linguistic variable speed might have the range
between 0 and 220 km/h and may include such
fuzzy subsets as very slow, slow, medium, fast, and
very fast.
 A linguistic variable carries with it the concept
of fuzzy set qualifiers, called hedges.
 Hedges are terms that modify the shape of fuzzy
sets. They include adverbs such as very,
somewhat, quite, more or less and slightly.
Fuzzy sets with the hedge very
Degreeof
Membership
1.0
Short Short
Tall
0.8
0.6 Average

0.4
Very Shor
t Very
VeryTall
Tall
Tall
0.2

0.0
150 160 170 180 190 200 210
Height, cm
Representation of hedges in fuzzy logic
Hedge Mathem atical Graphical Representa
tion
Expression

A little [A(x)]1.3

Slightly [A(x)]1.7

Very [A (x)]2

Extremely [A(x)]3
Representation of hedges in fuzzy logic (continued)
Mathematical
Hedge Graphical Representation
Expression

Very very [A ( x)]4

More or less A ( x)

Somewhat A ( x)

2 [A (x )]2
if 0  A  0.5
Indeed
1  2 [1  A ( x)]2
if 0.5 < A 1
Operations of fuzzy sets
The classical set theory developed in the late 19th
century by Georg Cantor describes how crisp sets can
interact. These interactions are called operations.
Cantor’s sets
Not A
B

A A
A

Complement Containment

A B A
A B

Intersection Union
 Complement
Crisp Sets: Who does not belong to the set?
Fuzzy Sets: How much do elements not belong to
the set?
The complement of a set is an opposite of this set.
For example, if we have the set of tall men, its
complement is the set of NOT tall men. When we
remove the tall men set from the universe of
discourse, we obtain the complement. If A is the
fuzzy set, its complement A can be found as
follows:
A(x) = 1  A(x)
 Containment
Crisp Sets: Which sets belong to which other sets?
Fuzzy Sets: Which sets belong to other sets?
Similar to a Chinese box, a set can contain other
sets. The smaller set is called the subset. For
example, the set of tall men contains all tall men;
very tall men is a subset of tall men. However, the
tall men set is just a subset of the set of men. In
crisp sets, all elements of a subset entirely belong to
a larger set. In fuzzy sets, however, each element
can belong less to the subset than to the larger set.
Elements of the fuzzy subset have smaller
memberships in it than in the larger set.
 Intersection
Crisp Sets: Which element belongs to both sets?
Fuzzy Sets: How much of the element is in both sets?
In classical set theory, an intersection between two
sets contains the elements shared by these sets. For
example, the intersection of the set of tall men and
the set of fat men is the area where these sets
overlap. In fuzzy sets, an element may partly
belong to both sets with different memberships. A
fuzzy intersection is the lower membership in both
sets of each element. The fuzzy intersection of two
fuzzy sets A and B on universe of discourse X:
AB(x) = min [A (x), B (x)] = A (x)  B(x),
where xX
 Union
Crisp Sets: Which element belongs to either set?
Fuzzy Sets: How much of the element is in either set?
The union of two crisp sets consists of every element
that falls into either set. For example, the union of
tall men and fat men contains all men who are tall
OR fat. In fuzzy sets, the union is the reverse of the
intersection. That is, the union is the largest
membership value of the element in either set. The
fuzzy operation for forming the union of two fuzzy
sets A and B on universe X can be given as:
AB(x) = max [A (x), B(x)] = A (x) B(x),
where xX
Operations of fuzzy sets
 (x)  (x)
B
1 1 A
A
0 0
x x
B
1 1 A
Not A
0 0
Complement x Containment x

 (x)  (x)

1 1
AB AB
0 0
x x
1 AB 1
AB
0 0
x x
Intersection Union
Additional operations

1. Equality: A = B, if µA(x) = µB(x), x  X


2. Not equal: A  B, if µA(x)  µB(x) for at least one x
X
3. Containment: A B if and only if µA(x)  µB(x), x  X
4. Proper subset: If A  B and A  B
5. Product: A.B is defined as µA.B(x) = µA(x) . µB(x)
6. Power : AN is defined as: µAN(x) = (µA(x))N
7. Bold union : A  B is defined as:
µA  B(x) = Min [1, µA(X) + µB(x)]
8. Bold intersection: A  B is defined as:
µA  B(x) = Max [0, µA(x) + µB(x) - 1]
Fuzzy rules
In 1973, Lotfi Zadeh published his second most
influential paper. This paper outlined a new
approach to analysis of complex systems, in which
Zadeh suggested capturing human knowledge in
fuzzy rules.
What is a fuzzy rule?
A fuzzy rule can be defined as a conditional
statement in the form:

IF x is A
THEN y is B

where x and y are linguistic variables; and A and B


are linguistic values determined by fuzzy sets on the
universe of discourses X and Y, respectively.
What is the difference between classical and
fuzzy rules?
A classical IF-THEN rule uses binary logic, for
example,
Rule: 1 Rule: 2
IF speed is > 100 IF speed is < 40
THEN stopping_distance is long THEN stopping_distance is short

The variable speed can have any numerical value


between 0 and 220 km/h, but the linguistic variable
stopping_distance can take either value long or short.
In other words, classical rules are expressed in the
black-and-white language of Boolean logic.
We can also represent the stopping distance rules in a
fuzzy form:
Rule: 1 Rule: 2
IF speed is fast IF speed is slow
THEN stopping_distance is long THEN stopping_distance is short

In fuzzy rules, the linguistic variable speed also has


the range (the universe of discourse) between 0 and
220 km/h, but this range includes fuzzy sets, such as
slow, medium and fast. The universe of discourse of
the linguistic variable stopping_distance can be
between 0 and 300 m and may include such fuzzy
sets as short, medium and long.
 Fuzzy rules relate fuzzy sets.
 In a fuzzy system, all rules fire to some extent,
or in other words they fire partially. If the
antecedent is true to some degree of
membership, then the consequent is also true to
that same degree.
Fuzzy sets of tall and heavy men
Degree of Degree of
Membership Membership
1.0 1.0
Tall men Heavy men
0.8 0.8
0.6 0.6

0.4 0.4
0.2 0.2
0.0 0.0
160 180 190 200 70 80 100 120
Height, cm Weight, kg

These fuzzy sets provide the basis for a weight estimation


model. The model is based on a relationship between a
man’s height and his weight:
IF height is tall
THEN weight is heavy
The value of the output or a truth membership grade of
the rule consequent can be estimated directly from a
corresponding truth membership grade in the
antecedent. This form of fuzzy inference uses a
method called monotonic selection.
Degree of Degree of
Membership Membership
1.0 1.0
Tall men
0.8 0.8 Heavy men
0.6 0.6

0.4 0.4

0.2 0.2

0.0 0.0
160 180 190 200 70 80 100 120
Height, cm Weight, kg
A fuzzy rule can have multiple antecedents, for
example:

IF project_duration is long
AND project_staffing is large
AND project_funding is inadequate
THEN risk is high

IF service is excellent
OR food is delicious
THEN tip is generous
The consequent of a fuzzy rule can also include
multiple parts, for instance:

IF temperature is hot
THEN hot_water is reduced;
cold_water is increased

You might also like