You are on page 1of 7

Knowledge-based systems Lecture 8

Membership Functions in the Fuzzy Logic Toolbox


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 sometimes referred to as the universe of discourse.
 The only condition a membership function must really satisfy is that it must
vary between 0 and 1.
 The Fuzzy Logic Toolbox includes 11 built-in membership function types.
These 11 functions are, in turn, built from several basic functions:
 Piecewise linear functions.
 Gaussian distribution function.
 Sigmoid curve.
 Quadratic polynomial curves.
 Cubic polynomial curves.
The simplest membership functions are formed using straight lines. These straight
line membership functions have the advantage of simplicity.
 Triangular membership function: trimf.
 Trapezoidal membership function: trapmf.
 Two membership functions are built on the Gaussian distribution curve: a
simple Gaussian curve and a two-sided composite of two different Gaussian
curves. The two functions are gaussmf and gauss2mf.
 The generalized bell membership function is specified by three parameters and
has the function name gbellmf.
 Sigmoidal membership function: sigmf.
 Polynomial based curves: Three related membership functions are the Z, S, and
Pi curves, all named because of their shape ( The functions zmf, smf and pimf).
Fuzzy Logic Toolbox also allows you to create your own membership functions.
Example:
x = (0:0.1:10)';
y1 = trapmf (x, [2 3 7 9]);
y2 = trapmf (x, [3 4 6 8]);
y3 = trapmf (x, [4 5 5 7]);
y4 = trapmf (x, [5 6 4 6]);
plot (x, [y1 y2 y3 y4]);

Prepared by: Dr. Intessar Al-Iedani 1


Knowledge-based systems Lecture 8

Fuzzy Inference System


A fuzzy inference system (FIS) is also known as fuzzy-rule-based system, fuzzy
expert system, fuzzy logic system, fuzzy model, fuzzy associative memory (FAM)
and fuzzy logic controller and fuzzy system.
An FIS is a computing framework based on the concepts of fuzzy set theory, fuzzy
(If-Then) rules and fuzzy reasoning. An FIS consists of 4 components:

Fuzzifiers: It maps the crisp (real-valued) input into a fuzzy set defined in the
universe of discourse (the domain of the fuzzy set) X characterised by membership
functions. This process is called fuzzification. Note: The input can also be a fuzzy
set.
Knowledge Base: It is a database consisting of linguistic rules in If-Then format.
Fuzzy Inference Engine: Using the If-Then rules in Knowledge base, it performs
reasoning by producing a fuzzy output according to the fuzzy input given by the
fuzzifier.
Defuzzifiers: It converts the fuzzy output given by the fuzzy inference engine to
produce a crisp (real-valued) output. This process is called defuzzifiaction.

Prepared by: Dr. Intessar Al-Iedani 2


Knowledge-based systems Lecture 8

Fuzzy rules:
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.
 Antecedent - The initial (or "if") part of a fuzzy rule.
 Consequent - The final (or "then") part of a fuzzy rule.
An example might be a temperature controller:
If the break temperature is HOT
and the speed is NOT VERY FAST
then break SLIGHTLY DECREASED.

What is the difference between classical and fuzzy rules?


A classical IF-THEN rule uses binary logic, for example,
Rule: 1
IF speed is > 100
THEN stopping_distance is long
Rule: 2
IF speed is < 40
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:

Prepared by: Dr. Intessar Al-Iedani 3


Knowledge-based systems Lecture 8

Rule: 1
IF speed is fast
THEN stopping_distance is long
Rule: 2
IF speed is slow
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.
Driving problem: I am driving and want to keep a safety distance between cars.
When the distance from the front car is x, what speed should I keep?

Linguistic Rules:
Rule 1: If distance is small Then speed is low
Rule 2: If distance is medium Then speed is steady
Rule 3: If distance is large Then speed is high
More specific question: When the distance from the front car is 3.5 m or so, what
speed should I keep? My Answer: The speed should be not very “low”, more
toward “steady” but definitely not “high”.

Prepared by: Dr. Intessar Al-Iedani 4


Knowledge-based systems Lecture 8

Fuzzy rules relate fuzzy sets:


In a fuzzy system, all rules fire to some extent, i.e., fire partially. If the
antecedent is true to some degree of membership, then the consequent is also true
to that same degree.
Example: Fuzzy sets of tall and heavy men.

Prepared by: Dr. Intessar Al-Iedani 5


Knowledge-based systems Lecture 8

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.

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

Prepared by: Dr. Intessar Al-Iedani 6


Knowledge-based systems Lecture 8

How are all these output fuzzy sets combined and transformed into a single
number?
To obtain a single crisp solution, a fuzzy expert system first aggregates all output
fuzzy sets into a single output fuzzy set, and then defuzzifies the resulting fuzzy
set into a single number.

Fuzzy Inference Engine


Fuzzy inference engine is to produce the fuzzy output according to the crisp inputs
based on the knowledge (knowledge base) represented by IF-THEN rule. This is
the process of reasoning. It generally involves two processes, i.e., rule evaluation
and rule aggregation
Rule evaluation (implication) is to apply the fuzzy set operators (AND, OR,
NOT) to the antecedents to determine the firing strength of each rule.
Rule aggregation is to combine the output (consequents) fuzzy sets using the
firing strengths obtained in the process of rule evaluation.

Three common fuzzy inference systems:


 Mamdani fuzzy inference systems
 Sugeno fuzzy inference systems (also known as Sugeno fuzzy models, TSK
(Takagi, Sugeno, and Kang) fuzzy models)
 Tsukamoto fuzzy inference systems (also known as Tsukamoto fuzzy
models)
The main difference is in the consequents of the IF-THEN rules
Mamdani FIS: Consequent membership function is a general membership function
Sugeno FIS: Consequent membership function is a mathematical function
Tsukamoto FIS: Consequent membership function is a monotonic membership
function (a shoulder function)

Prepared by: Dr. Intessar Al-Iedani 7

You might also like