Fuzzy Math, Part 1, The Theory

If you are interested in a very flexible rule-based system and want it to be easily integrated with for instance adaptive systems, then fuzzy logic provides a good solution.
So what is fuzzy logic?
Take a look at the first sentence in this text. Expressions like “very flexible”, “easily integrated” and “good solution” were used. This type of vague expressions are characteristic of the way we humans communicate through language and as such is an integral part of our thinking process. This contrasts sharply with the traditional Boolean logic of computer programming. Fuzzy logic bridges the gap between them, providing a framework that allows you to numerically encode linguistic expressions and through that gives you a flexible rule-based system.
This is the first part of a two-part tutorial and will cover the basic fuzzy logic theory. The second part will be more practical and deal with fuzzy logic in Synapse and the creation of hybrid fuzzy-adaptive systems.
0 or 1?
The traditional way of the computer is binary, either true (1) or false (0) and nothing in-between. There are some great advantages to digital representation, but ultimately we live in an analogue world and when describing it we are used to analogue terms defined through language. Suppose we say “Bob is tall”. How would we quantify that? In the digital world, it would look something like this:

However, this would mean that while Bob, who is 180.1 cm in height is tall, while Frank who is 179.9 cm is not. That doesn’t really reflect the way we would normally think. Instead, we would probably say that Bob and Frank are both rather tall. A fuzzy representation of the “tall” variable would look perhaps something like this:

As you can see, no sharp boundary at 180 cm, but a smooth transition. On the vertical axis we have “Membership Degree”, indicating to what degree the value of a variable is in a set. In the digital world, membership degree can be 1 or 0, but in the fuzzy world it can be any value between 0 and 1. To understand this, let’s expand on this example and look at a problem involving several regions. Suppose we wish to divide height into three classes: short, average and tall. A Boolean representation would perhaps look something like this:

Again we see those sharp boundaries. A fuzzy representation on the other hand might look something like this:

Note how the regions are overlapping - this is one fundamental feature of fuzzy sets: membership in a set isn’t exclusive. A person that is 165 cm in height is a member of both the “Short” and the “Average” sets. Also note that there is nothing preventing you from creating Boolean (sharp) sets by using fuzzy logic. The regular Boolean logic is in fact a special case of the more general fuzzy logic.
So, how do we read the graphs above? Suppose height is 182 cm. Find the value on the horizontal axis and see where it intersects the membership functions for the three variables. The membership functions are in this case triangle shaped.

182 cm is outside the range of “Short”, so short = 0, It intersects average at 0.4 and tall at 0.08. Also note that the values are not normalized, so the sum of membership degrees doesn’t have to add up to 1.
Set Logic
To be able to express ourselves with this new fuzzy thing, we need some basic rules. Our ultimate goal is to be able to define logical expressions that we later can turn into statements.
There are three relevant operators in the fuzzy set logic: OR, AND and NOT. They also obviously exist for regular Boolean logic, but we need to expand their definition to support our new non-sharp membership functions:

How do we apply this? Let’s look at two examples. Suppose we introduce a new variable, “Weight” and in the same way we divided “Height”, we divide this one into “Light”, “Average” and “Heavy”.
Let Height = 165 and Weight = 100. If we wanted to say “Height is short or Weight is heavy”, it would look something like this:

As we did before, to find out the membership degree, we see the value of the membership function (vertical axis) for the variable value. We do this for both Height and Weight and then apply the OR rule (which is simply the maximum value).
In the same way if wee look at the AND rule:

Rules and hedges
A fuzzy rule is assembled as follows:
IF antecedent THEN consequent
- Antecedent:
“height is tall and weight is light) or (weight is average and height is short” - Consequent:
“price is high”
Before putting it all together, there is one final concept we need to look at - hedges. When communicating in a natural language a form of mitigating device is commonly used to weaken or strengthen the impact of an statement. We might say “That’s a very big house” or “The answer was more or less correct” or “She felt slightly uncomfortable”. “Very”, “more or less” and “slightly” are all examples of hedges.
In terms of fuzzy logic, hedges are operators that are applied on the membership function. The operators are defined in such a way to reflect their linguistic meaning and they create a sort of virtual set. For instance a “very” hedge would have this effect:

So for instance a person with a height of 185 cm would be a member of Tall set, but not of the Very Tall set. A person with a height of 190 cm on the other hand would be member of both.
Here are some examples of hedges that are supported in Synapse (the pictures show the effect of the hedges on a triangle shaped membership function):
| Hedge | Operator | Effect |
| A little | ![]() |
|
| Slightly | ![]() |
|
| Very | ![]() |
|
| Extremely | ![]() |
|
| Very very | ![]() |
|
| Somewhat | ![]() |
|
| Indeed | ![]() |
![]() |
Fuzzy Inference
When we put it all together we can construct fuzzy inference systems. Fuzzy inference consists of basically four distinct steps:
- Fuzzification
This is the mapping from “crisp” numerical values to the membership functions of the fuzzy variables. - Rule evaluation
The rules defined are evaluated using the set logic we defined earlier. - Aggregation
The results of the rules are aggregated so that they are mapped to the output variables. - Defuzzyfication
The final step is the mapping from fuzzy output variables to crisp numerical values
Example
Suppose we want to design a risk-assessment system for some form of project. We wish to determine the risk depending on project funding and staffing. The fist step is to design our fuzzy variables, which are funding, staffing and risk. For each of these variables, we define the membership functions:

The next step is to define the rules for the system, using these variables. For instance one such set of rules may be:
- If funding is adequate or staffing is small then risk is low
- If funding is marginal and staffing is large then risk is normal
- If funding is inadequate then risk is high
Suppose we have a funding of f0 € and a staffing of s0 people. What would the risk r0 be?
The first step, fuzzification is done like this:

We have mapped the “crisp” (i.e. raw values) f0 and s0 to the membership functions and found (for instance) that f0 has a 0.5 membership degree of “inadequate” and a 0.2 membership degree of “marginal”. The same way s0 has a 0.1 membership degree of “small” and 0.7 membership degree of “large”.
The next step is to evaluate the rules we have defined:



After we have evaluated all the rules, we aggregate the results to a single output area:

The output area is then deffuzified to get a crisp (i.e. single numerical) output r0. There are a number of methods of how you can do that, but a common solution is to take the center of mass of the result output area:

Normally the software (like Synapse) that you use handle the whole thing. Generally speaking, what is left to you is to define the initial membership functions and the rules while the evaluation is handled automatically. However, it is still good to know the basic principles of operation even if you are never going to do it manually.
Discussion
Fuzzy logic is a powerful tool for defining systems through a natural use of language. It is more flexible and corresponds better to our analogue world than traditional Boolean logic. However as with any tool, you must know when to use it and as always there is no such thing as a free lunch: it comes with a cost. The principal problem of defining a fuzzy system is not only that you must know the rules but also that you have to define the membership functions. Compared to adaptive systems, such as neural networks, that autonomously learn from data it may seem like an unnecessary hassle. There are however situations where you have expert knowledge that you wish to include in the system.
Data is seldom perfect, and giving an adaptive system a helping hand by a fuzzy preprocessing stage can help a lot. Fuzzy systems are especially good when they are combined with adaptive systems as the two complement each other and the adaptive system can compensate for the shortcomings of the fuzzy model (such as incorrect rules or badly defined membership functions).
There are also ways of doing a mapping of a neural network to do what the fuzzy system does (for instance ANFIS - Adaptive-Network-Based Fuzzy Inference System), which allows you to automatically extract fuzzy rules from data. Such neuro-fuzzy systems on the other hand have some problems of their own and the most powerful, useful and simple arrangement is to use a classical fuzzy system in combination with an adaptive system.
In the next tutorial we shall take a look at how you can use the Fuzzy Logic component in Synapse to do so.
Luka Crnkovic-Dodig / Peltarion








Entries (RSS)
November 11th, 2006 at 1:17
Great article, very comprehensive and interesting!
November 23rd, 2006 at 3:25
[...] Fuzzy Math: Theory : For anyone who has ever wanted the catch-all solution to a problem that either required more involved users or defined procedures. A great read even for those of us who hate math (present company included). Take a look at the first sentence in this text. Expressions like “very flexible”, “easily integrated” and “good solution” were used. This type of vague expressions are characteristic of the way we humans communicate through language and as such is an integral part of our thinking process. This contrasts sharply with the traditional Boolean logic of computer programming. Fuzzy logic bridges the gap between them, providing a framework that allows you to numerically encode linguistic expressions and through that gives you a flexible rule-based system. [...]
November 28th, 2006 at 16:09
[...] Synaptic The Peltarion Blog « Fuzzy Math, Part 1, The Theory [...]
December 12th, 2006 at 17:14
Thanks to the editor who has provided such a beautiful article available in net.
December 16th, 2006 at 9:27
Thnak you so much for the editer who write such an existing article… we need more if you could
January 16th, 2007 at 1:14
[...] There is a list of more hedges available at Synaptic: The Peltarion blog which includes quantifiers such as “a little”, “slightly” and “extremely”. The majority of the quantifiers are simply the membership function raised to a particular power. This power being greater than unity for “more” quantifiers and being less than unity for “less” quantifiers. Given that, the “indeed” hedge as described is of more interest as it adopts an “S” shape, so that at extremes of the domain, it acts as “very” but towards the middle acts as “somewhat” [...]
February 6th, 2007 at 2:55
Nice paper, Id like to see some more, if you could..
February 24th, 2007 at 8:21
Excellent overview. Thanks a lot
April 5th, 2007 at 9:09
Described in simpl words and using good and easy to understand examples.The writer has really done a good job.We need more of these kind of valuable data from your lap sir.
god bless
April 29th, 2007 at 23:47
Very clear article. Thanks..
May 4th, 2007 at 14:19
nice about the fuzzy sets but clear explanation with how to design the fuzzy sets are required as the view and the look of one person varies , eg in Japan Normal height people are much shorter in other areas and the like
July 16th, 2007 at 12:06
good
August 6th, 2007 at 4:36
[Also note that the values are not normalized, so the sum of membership degrees doesn’t have to add up to 1.]
I think I can guess why you said this, this way, here goes: new people to fuzzy theory think of fuzzy sets in terms of probabilities or compare it with it. Since “normalized” in probability theory basically means adding up to 1, you stick with their terminology. I’d just like to point out that according to many fuzzy set texts such as Klir and Yuan, Ngyuen and Walker, Buckley and Eslami, and Zadeh’s paper use “normalized” to mean that sup{F}=1 (or max{F} when F is finite), where F indicates our fuzzy set. So, many fuzzy set theorists would call your sets short, medium, and tall “normalized.” I’d suggest that you edit this any say something “normalized in the sense of probability theory” or something similar.
Nice essay.
August 28th, 2007 at 18:28
Very good clear explanation, Thanks!!!
January 6th, 2008 at 21:46
I think it’s an elegant overview. It managed to explain things “on fingers”. Thanks
August 17th, 2008 at 11:03
Thank you
November 1st, 2008 at 13:31
When the part 2 will be available?