0% found this document useful (0 votes)
19 views18 pages

Unit 2 Notes

The document provides an overview of Fuzzy Theory, detailing the concepts of fuzzy sets, fuzzy logic, and their applications in computational intelligence. It contrasts fuzzy sets with classical sets, emphasizing the flexibility and partial membership of fuzzy sets, and introduces key components of fuzzy expert systems. The document also includes examples of fuzzy operations and membership functions, illustrating their practical use in real-world scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views18 pages

Unit 2 Notes

The document provides an overview of Fuzzy Theory, detailing the concepts of fuzzy sets, fuzzy logic, and their applications in computational intelligence. It contrasts fuzzy sets with classical sets, emphasizing the flexibility and partial membership of fuzzy sets, and introduces key components of fuzzy expert systems. The document also includes examples of fuzzy operations and membership functions, illustrating their practical use in real-world scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Fuzzy Theory

Computational Intelligence Notes


Dr. Ashish Ranjan
Unit 2 – Fuzzy Theory
M2. Fuzzy Theory (08 Hrs)
Fuzzy Set Theory: Exploring the concepts of crisps and fuzzy sets. Crisp and fuzzy relations,
Fuzzy Systems: Comparing crisp logic with predicate logic, fuzzy Rule based system,
Defuzzification Methods, Fuzzy rule based reasoning, fuzzy inference engine, and knowledge
base. Exploring different fuzzy models and proficiency in applying fuzzy logic concepts to
real-world scenarios.

1. Introduction:

Soft computing is a modern computing methodology that relies on the


principles of approximation, flexibility, and uncertainty, for solving the real-
world problems. The term "soft computing" was first coined by Dr. Lotfi
Zadeh. According to him, soft computing is a methodology that imitates the
human brain to reason and learn in an uncertain environment.

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 1


Fuzzy Theory

Hard computing, on the other hand, is a conventional computing method


which relies on the principles of accuracy, inflexibility, and certainty.

2. Fuzzy Set:

Note:
a) A fuzzy set is a set without a crisp, clearly defined boundary.
b) It can contain elements with only a partial degree of membership.

a) A classical set, also termed crisp set, is a container that wholly includes
or wholly excludes any given element. For example, the set of days of the
week unquestionably includes Monday, Thursday, and Saturday.

Monday Properly defined


Days of Thursday
week Saturday elements

Set boundary is very clear, and partial degree of membership allowed.

b) However, a set of weekend can be difficult to define. For example, the


set of days of the week-end unquestionably includes Saturday and
Sunday, but different human-beings have different argument about
Friday. For some, it may be partially a week-end only.
7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 2
Fuzzy Theory

Monday

Saturday Friday Not clear or vaguely


Days of
week-end Sunday defined elements

Clearly, the inclusion of Friday in the set is somewhat not clear, and
precisely depends upon the human perception. This is where the
classical set fails and fuzzy set works.
Thus, this clearly illustrate that fuzzy set has no crisp boundary
and also include elements with the partial membership.

Note:
a) In fuzzy logic, the truth of any statement is a matter of degree.
b) The major advantage that fuzzy reasoning offers is the ability to reply
to a yes-no question with a not-quite-yes-or-no answer.

Binary vs Multi-valued System


1.2

0.8
Two-valued
0.6 Membership
0.4 Multi-valued
Membership (Fuzzy)
0.2

0
Thursday Friday Saturday Sunday Monday

Question: Is Thursday a weekend day?


Answer: 0.0 (No or False)
Question: Is Friday a weekend day?
Answer: 0.25 (for the some part yes, but not completely)

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 3


Fuzzy Theory

Days of weekend two-valued Days of weekend multi-valued


membership membership

By making the plot continuous, you define the degree to which any given
instant belongs in the weekend rather than an entire day.
a) In the left plot, at midnight on Friday, the weekend-ness truth value
jumps discontinuously from 0 to 1.
b) The right plot shows a smoothly varying curve that accounts for the fact
that Friday, to some degree, is a part of weekend-ness and thus deserves
partial membership in the fuzzy set of weekend moments.

Note:
The curve that defines the weekend-ness of any instant in time is a function
that maps the input space (time of the week) to the output space (weekend-
ness). Such a function is a membership function.

3. Classical Set Vs Fuzzy Set:

Feature Classical Set Fuzzy Set


Membership Binary (0 or 1). Continuous ( Between 0 to 1)
Boundaries Well defined and Sharp Soft
Uncertainty No Yes
Handling
Example Tall people = height ≥ 6 ft Tallness varies between 5’5"
and 6’5"

4. Characteristics of Fuzzy Set:

 Soft boundaries: Elements can partially belong to the set.


 Uses a membership function: Assigns a value between 0 and 1.
 More flexible for real-world problems: involving vagueness and
uncertainty.

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 4


Fuzzy Theory

5. Membership Function:

A membership function (MF) is a curve that defines how each point in the
input space is mapped to a membership value (or degree of membership)
between 0 and 1. The input space is often referred to as the universe of
discourse.

Examples: Consider the set of tall people, where the universe of discourse is
all potential heights; say from “Four” feet to “Seven” feet. The
word tall corresponds to a curve that defines the degree to which any
person is tall.
 If the set of tall people is given the well-defined (crisp) boundary of a
classical set, you might say all people taller than “Six” feet are
officially considered tall.
A classical set (A) can be defined as:
A = {x | x> 6}

 However, it is unreasonable to call one person short and another one


tall when they differ in height by an inch.

Question: What is the right way to define the set of tall people?

Answer: A smoothly varying curve that passes from not-tall to tall. The
output axis is a number known as the membership value between 0 and 1.
The curve is known as a membership function and is often given the
designation of µ.

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 5


Fuzzy Theory

For example, the following figure shows both crisp and smooth tall
membership functions. In the top plot, the two people are classified as
either entirely tall or entirely not-tall.

In the bottom plot, the smooth transition allows for different degrees of
tallness. Both people are tall to some degree, but one is significantly less tall
than the other. The taller person, with a tallness membership of 0.95 is
definitely a tall person, but the person with a tallness membership of 0.3 is
not very tall.
ss

A fuzzy set is an extension of a classical set. If X is the universe of discourse


and its elements are denoted by x, then a fuzzy set A in X is defined as a set
of ordered pairs.
A = {x, μA(x)| x∈X}

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 6


Fuzzy Theory

Where,
µA(x) is called the membership function (or MF) of x in A, such that it lies
in a range [0, 1]

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 7


Fuzzy Theory

6. Logical Operations:
The fuzzy logical reasoning is the superset of standard Boolean logic. In
other words, if you keep the fuzzy values at their extremes of 1 (completely
true), and 0 (completely false), standard logical operations hold.

In fuzzy logic, the truth of any statement is a matter of degree, can these
truth tables be altered? The input values can be real numbers between 0
and 1.

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 8


Fuzzy Theory

Example 1: Consider two fuzzy sets:


1.0 0.3 0.5 0.2
𝐴={ + + + }
2 4 6 8
0.5 0.4 0.1 1.0
𝐵={ + + + }
2 4 6 8
Solution:
A) Union:
A U B = max{μA(x), μB(x)}
1.0 0.4 0.5 1.0
={ + + + }
2 4 6 8
B) Intersection:
A ∩ B = min{μA(x), μB(x)}
0.5 0.3 0.1 0.2
={ + + + }
2 4 6 8
C) Compliment:
A’ = 1 - μA(x)
0.0 0.7 0.5 0.8
={ + + + }
2 4 6 8

B’ = 1 - μB(x)
0.5 0.6 0.9 0.0
={ + + + }
2 4 6 8
D) Difference:
A | B = A ∩ B’
0.5 0.3 0.5 0.0
={ + + + }
2 4 6 8

B| A = B∩A’
0.0 0.4 0.1 0.8
={ + + + }
2 4 6 8

Example 2: Given Gain and detection levels of two sensors.


Gain Detection Level Detection Level
(Sensor 1) (Sensor 2)
0 0 0
10 0.2 0.35
20 0.35 0.25
30 0.65 0.8

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 9


Fuzzy Theory

40 0.85 0.95
50 1.0 1.0

Solution: Converting them into fuzzy sets:


0.0 0.2 0.35 0.65 0.85 1.0
𝑆1 = { + + + + + }
0 10 20 30 40 50
0.0 0.35 0.25 0.8 0.95 1.0
𝑆2 = { + + + + + }
0 10 20 30 40 50
A) Union:
S1US2 = max{μs1(x), μs2(x)}
0.0 0.35 0.35 0.8 0.95 1.0
={ + + + + + }
0 10 20 30 40 50

B) Intersection:
S1∩S2 = max{μs1(x), μs2(x)}

0.0 0.2 0.25 0.65 0.85 1.0


={ + + + + + }
0 10 20 30 40 50
C) Compliment:
S1’ = 1 - μS1(x)
1.0 0.8 0.65 0.35 0.15 0.0
={ + + + + + }
0 10 20 30 40 50

S2’ = 1 - μS2(x)
1.0 0.65 0.75 0.2 0.05 0.0
={ + + + + + }
0 10 20 30 40 50

Example 3: Using the inference approach, find the membership values for
the triangular shapes I, R, E, IR and T for a triangle with angles 45°, 55° and
80°.

Solution:
Let the universe of discourse be:
U = {(X, Y, Z): X = 80°, Y = 55°, Z = 45°and X + Y + Z = 180°}

a) Membership value of isosceles triangle (I):


1
𝜇𝑰 = 1 − min (𝑋 − 𝑌, 𝑌 − 𝑍)
60°
7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 10
Fuzzy Theory

1
=1− min (80° − 55°, 55° − 45°)
60°
1
=1− min (25°, 10°)
60°
1
=1− ∗ 10° = 1 − 0.1667 = 𝟎. 𝟖𝟑𝟑
60°

b) Membership value of right-angle triangle (R):


1
𝜇𝑹 = 1 − |𝑋 − 90°|
90°
1
=1− ∗ 10° = 𝟎. 𝟖𝟖𝟗
90°

c) Membership value of equilateral triangle (E):


1
𝜇𝑬 = 1 − (𝑋 − 𝑍)
180°
1
=1− ∗ (80° − 45°)
180°
1
=1− ∗ 35° = 𝟎. 𝟖𝟎𝟓𝟔
180°

d) Membership value of isosceles and right-angle triangle (IR):


𝜇𝑰𝑹 = min[𝜇𝑰 , 𝜇𝑹 ] = 𝟎. 𝟖𝟑𝟑

e) Membership value of other triangle (T):


𝜇𝑻 = min[1 − 𝜇𝑰 ,1 − 𝜇𝑬 ,1 − 𝜇𝑹 ]
= min[0.167, 0.1944, 0.111]
= 𝟎. 𝟏𝟏𝟏

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 11


Fuzzy Theory

7. Fuzzy Expert System:


A Fuzzy Expert System (FES) is an expert system that incorporates fuzzy
logic to handle uncertainty, vagueness, and imprecise information. Unlike
traditional rule-based expert systems that use crisp logic (true/false), fuzzy
expert systems can work with degrees of truth.

Input

Fuzzification
Engine

Knowledge Inference
Base Engine

DeFuzzification
Engine

Output

Key Components of a Fuzzy Expert System


1. Fuzzification Module:
o Converts crisp inputs into fuzzy values using membership functions.
o Example:
Temperature = 35°C → "Warm" with 0.7 membership,
"Hot" with 0.3 memberships.

2. Knowledge Base
o Contains fuzzy rules (IF-THEN rules) and membership functions.
o Example rule:
IF temperature is HIGH AND humidity is LOW,
THEN fan speed is FAST.

3. Inference Engine
o This is the core reasoning unit that applies fuzzy logic to the rules.

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 12


Fuzzy Theory

o It evaluates which rules are triggered and determines the fuzzy


output.
o Two common inference methods:
1) Mamdani Method (produces fuzzy outputs)
2) Sugeno Method (produces crisp outputs directly)

4. Defuzzification Module
o Converts fuzzy outputs back into crisp values.
o Example: "Fan speed is FAST" → 80% power.

Example 1: Determine the fuzzy linguistic sets for service, food and tip for the
problem given in the figure.

Answer:
a) Service: {poor, good, excellent}
b) Food: {rancid, delicious}
c) Tip: {cheap, average, generous}

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 13


Fuzzy Theory

Example 2: Controlling a fan speed based on temperature and humidity using


the Mamdani method.

A) Problem Definition:

We want to control the speed of a fan based on two inputs:


 Temperature (°C) → {Low, Medium, High}
 Humidity (%) → {Low, Medium, High}

The output is:


 Fan Speed (%) → {Slow, Medium, Fast}

B) Define Fuzzy Sets (Membership Functions):

B.1. Membership for temperature:

Temperature Low Medium High


0 1.0 0.0 0.0
10 0.5 0.5 0.0
20 0.0 1.0 0.0
30 0.0 0.5 0.5
40 0.0 0.0 1.0

B.2. Membership for humidity:

Humidity (%) Low Medium High


0 1.0 0.0 0.0
30 0.5 0.5 0.0
50 0.0 1.0 0.0
70 0.0 0.5 0.5
90 0.0 0.0 1.0

B.3. Membership for fan speed:

Fan Speed (%) Slow Medium Fast


0 1.0 0.0 0.0
25 0.5 0.5 0.0
50 0.0 1.0 0.0
75 0.0 0.5 0.5
100 0.0 0.0 1.0

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 14


Fuzzy Theory

1.2

0.8

0.6

0.4

0.2

0
0 25 50 75 100
Slow Medium High

C) Define Fuzzy Rules:


1. IF Temp. is High AND Humidity is Low, THEN Fan Speed is Fast.
2. IF Temp. is High AND Humidity is High, THEN Fan Speed is Medium.
3. IF Temp. is Medium AND Humidity is Medium, THEN Fan Speed is Medium.
4. IF Temp. is Low AND Humidity is High, THEN Fan Speed is Slow.
5. IF Temp. is Low AND Humidity is Low, THEN Fan Speed is Medium.

D) Applying Mamdani Inference Steps:

Step 1: Fuzzification
Let’s assume:
 Temperature = 35°C
 Humidity = 30%

From the membership tables:


 Humidity = 30% falls into Low (0.5) and Medium (0.5).
 Temperature = 35°C(needs to be computed).

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 15


Fuzzy Theory

1. Membership in "Low":(x = 35, b = 0°C, c = 20°C)


Therefore, µlow(35) = 0.0

2. Membership in "Medium": (x = 35, a = 0°C,b = 20°C, c = 40°C)


Therefore, µmedium(35) = 5/20 = 0.25

3. Membership in "High": (x = 35, a = 20°C,b = 40°C)


Therefore, µhigh(35) = 15/20 = 0.75

Step 2: Rule Evaluation (Using MIN function)


We calculate the firing strength of each rule using MIN(µ(T), µ(H)):

Rule µ(T) µ(H) MIN(µ(T), µ(H)) Fan Speed


Temp. = High, 0.75 0.5 0.5 Fast
Humidity = Low
Temp. = High, 0.75 0.0 0.0 Medium
Humidity = High
Temp. = Medium, 0.25 0.5 0.25 Medium
Humidity = Medium
Temp. = Low, 0.0 0.0 0.0 Slow
Humidity = High
Temp. = Low, 0.0 0.5 0.0 Medium
Humidity = Low

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 16


Fuzzy Theory

So, the active rules and their fuzzy outputs are:

 Rule 1 → Fast (0.5)


 Rule 3 → Medium (0.25)

E) Aggregation of Rule Outputs (Using MAX function):

Since we have two active rules affecting Fan Speed, we take the maximum
fuzzy value for overlapping outputs:

 Fan Speed Medium → 0.25


 Fan Speed Fast → 0.5

1.2

0.8

0.6

0.4

0.2

0
0 25 50 75 100
Medium High

F) Defuzzification (Using Centroid Method)

The Crisp Fan Speed Output (S)* is computed using the Centroid Method (i.e.,
centre of sum method):

Area of Trapezoid (red) = 0.5 * (75 + 100) * 0.25 = 21.87


Centre of Trapezoid (red) = 50
Area of Trapezoid (yellow) = 0.5 * (25 + 50) * 0.50 = 18.75
Centre of Trapezoid (yellow) = 25

Therefore, final fan speed = ((21.87 * 50) + (18.75 * 25)) / (21.87 + 18.75)
= (1093.50 + 468.75) / 40.62 = 38.46%

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 17


Fuzzy Theory

8. Crisp Logic vs Predicate Logic


Feature Crisp Logic (Boolean Logic) Predicate Logic (FOL)
Truth Values Binary (True/False) Can handle multiple entities

Scope Whole statements Objects & their relationships


Quantifiers None Uses ∀ (forall), ∃ (exists)
Operators AND, OR, NOT AND, OR, NOT, ∀, ∃, →
Complexity Simpler More expressive & powerful
Applications Circuits, databases, programming AI, theorem proving, semantic web

9. References:
a. https://in.mathworks.com/help/fuzzy/foundations-of-fuzzy-logic.html

7th Semester (B. Tech.) (Dr. Ashish Ranjan) Page 18

You might also like