Saturday, December 25, 2010

QS - Fuzzy Logic in a Nutshell

Suppose you are driving to a theater you have never been to before. You are on the correct street, but are unsure of the exact location of the building. Rolling down your window, you ask a passing pedestrian where it is. The reply that comes is: ``Drive a little farther, and you will see it to your left." From there, finding the theater is almost trivial, as you intuitively follow your notion of what ``a little farther" is. Mathematically, however, those words are not so straightforward. What does “a little farther" mean? The phrase is fuzzy

Another good example is that of colours.  Take a look at the picture of the green shamrocks. Each shamrock has a different 'shade' of green. Some even have yellow splashed on! So what is "green"? The colour is fuzzy!


Lotfi Zadeh founded Fuzzy Set Theory (FST) in 1964, to make set theory more intuitive and applicable to the real world.  FST adds to the 'intelligence' of machines. Here's an apt quote by Bart Kosko and Satoru Isaka:

“The binary logic of modern computers often falls short when describing the vagueness of the real world. Fuzzy logic offers more graceful alternatives.”

FST is different from Classical Set Theory, which says that an object either belongs to a set or it does not. In school, we learned that all hypothetical objects can be divided into sets – groups of like objects. If a particular object does not lie within a set, then it belongs to the set’s compliment. In real life, however, we cannot classify things so easily.

Let's look at the shamrock example again. In FST we could define a set called "Green". Each of the different shades would lie to different extents within the set. Associated to each shade would be a membership number, i.e., a number that indicates how much the shade lies within the set Green. Therefore, a fuzzy set can be thought of as a bunch of memberships. Once we define a set, we can compare two or more shades of green. We’d be able to say this colour is greener than that one, for it lies to a greater extent within our defined set, i.e., it has a higher membership. I won’t get into technical details just yet.

Now that I’ve explained on a very basic level what fuzzy logic is, let’s look at why it’s useful. Fuzzy logic has its home in the realm of Artificial Intelligence, or “the science and engineering of making intelligent machines” according to John McCarthy who coined the term in the first place. An intelligent machine is one that bases its actions on its environment. Basically, it perceives what is going on, and makes proper decisions. The decisions are made based on fuzzy IF-THEN rules.

There are a myriad applications for fuzzy logic. It’s used to regulate temperatures and/or water levels in air conditioners, washing machines, dishwashers, microwaves and more. It’s used in digital image processing, robotics, and classification algorithms. It's even used in medical diagnosis.

A very interesting application is MASSIVE (Multiple Agent Simulation System in Virtual Environment), which is a software package used for generating crowd-related visual effects for film and television. Movies like Avatar and Lord of the Rings have included MASSIVE to depict large-scale armies enacting random yet orderly movements.

Slightly more Technical – Only Slightly!

A fuzzy set can be thought of as a membership function that lets us know to what an extent an object lies in a particular set. Let’s take the hypothetical example I started with - that of finding the theater. Consider a fuzzy set How-Far which defines the farthest possible distance from where you are as 100 meters.  Therefore, any object that lies 100 meters away from you will lie completely within the set, with the highest possible membership of 1. (As this is a hypothetical example, we shall assume distances beyond 100 meters are not possible.)  If the theater was 30 meters away from you, then it would have a membership of .3 within the set.  Therefore, without knowing it, the pedestrian actually described an object with the membership of .3 as being ``a little farther" away, thereby giving a mathematical meaning to these words!

Without getting into the mathematics of FST, here are a couple of points to keep in mind about fuzzy sets and memberships:
  • Memberships lie in the interval [0,1]
  • If an object does not lie in the set, it has a membership of 0
  • If an object lies completely within the set, it has a membership of 1
  • Fuzzy sets can have a number of shapes, such as those shown in the figure.

These are just two examples of the many shapes that a fuzzy set can take.  Another common fuzzy set is the Gaussian.  In the example given, the attribute value would be the distance from where you are.  So, the theater would have an attribute value of 30 meters, with a membership of .3.

Fuzzy decision systems use pairs of fuzzy sets in the form of IF-THEN rules in order to make decisions.  I won'te get into decision systems right now, but there are plenty of awesome materials out there to leaf through if you're interested!

Here are a few:

Basic Understanding for Beginners

Fuzzy Thinking: The New Science of Fuzzy Logic by Bart Kosko
Fuzzy Logic: The Revolutionary Computer Technology That Is Changing Our World by Daniel Macneil

For Further Study

Fuzzy Sets, Fuzzy Logic, and Fuzzy Systems: Selected Papers by Lotfi A Zadeh edited by George J Klir  & Bo Yuan
Fuzzy Models and Algorithms for Pattern Recognition and Image Processing by James C. Bezdek, James Keller, Raghu Krisnapuram, and Nikhil R. Pal


MATLAB & Simulink based books:


  1. I did my B.Sc(Engg.) project on "Fuzzy Synthetic Evaluation" in Dayalbagh. Even then my concepts of Fuzzy are still Fuzzy. Your post gives a very lucid introduction to fuzzy. But I guess applying it to the real world problem is quite complex.

  2. Thanks for the comment, Vinay!

    At first, applying anything that we've studied to the real world seems intimidating --I know I still get intimidated from time to time. However, plenty of models and examples exist in the literature, so if one keeps up to date it's not that difficult to assess which would best suit a problem.

    Of course, certain parameters and steps may have to change based on the problem, but that's what makes it even more fun! The key is to take things one step at a time.

  3. You have literally saved my report with this concise and easy to understand explanation, thank you so much!

  4. Cool, glad I could help! Thanks for stopping by.