Sunday 18 January 2009

Fuzzy Logic Notes

Fuzzy logic is a superset of conventional (boolen) logic that has been extended to handle the concept of partial truth – truth values between “completely true” and “completely false”. It was introduced by Dr. Lotfi in the 1960's as a means to model the uncertainty of natural language.

Zadeh says that rather than regarding fuzzy theory as a single theory, we should regard the process of “fuzzification” as a methodology to generalize any specific theory from a crisp (discrete) to a continuous (fuzzy) form.

Fuzzy Subsets

Just as there is a strong relationship between Boolean logic and the concept of a fuzzy subset, there is a similar strong relationship between fuzzy logic and fuzzy subset theory.

In classical set theory, a subset U of a set S can be defined as a mapping from the elements of S to the elements of the set {0,1},

U : S → {0,1]

This mapping may be represented as a set of ordered pairs, with exactly one ordered pair present for each element of S. The first element of the ordered pair is an element of the set S, and the second element is an element of the set {0,1}. The value zero is used to represent non-membership, and the value one is used to represent membership. The truth or falsity of the statement

x is in U

is determined by finding the ordered pair whose first element is x. The statement is true if the second element of the ordered pair is 1, and the statement is false if it is 0.

Similarly, a fuzzy subset F of a set S can be defined as a set of ordered pairs, each with the first element from S, and the second element from the interval [0,1], with exactly one ordered pair present for each element of S. This defines a mapping between elements of the set S and values in the interval [0,1]. The value zero is used to represent complete non-membership, the value one is used to represent intermediate degrees of membership. The set S is referred to as the universe of discourse for the fuzzy subset F. Frequently, the mapping is described as a function, the membership function of F. The degree to which the statement

x is in F

is true is determined by finding the ordered pair whose first element is x. The degree of truth of the statement is the second element of the ordered pair.

In practice, the terms “membership function” and fuzzy subset get used interchangebly.

An Example:

Let's talk about people and “tallness”. In this case the set S (the universe of discourse) is the set of people. Let's define a fuzzy subset TALL, which will answer the question “to what degree is person x tall?” Zadeh describes tall as a linguistic variable, which represents our cognitive category of “tallness”. To each person in the universe of discourse, we have to assign a degree of membership in the fuzzy subset TALL. The easiest was to do this is with a membership function based on the persons height.


    tall(x) = { 0,                                 if height(x) <>            (height(x)-5ft.)/2ft.,       if 5 ft. <= height (x) <= 7 ft.,            1,                                    if height(x) > 7 ft. }


A graph of this looks like:  1.0 +                   +-------------------     |                  /     |                 / 0.5 +                /     |               /     |              / 0.0 +-------------+-----+-------------------                   |     |                  5.0   7.0                  height, ft. -> Given this definition, here are some example values:  Person    Height    degree of tallness -------------------------------------- Billy     3' 2"     0.00 [I think] Yoke      5' 5"     0.21 Drew      5' 9"     0.38 Erik      5' 10"    0.42 Mark      6' 1"     0.54 Kareem    7' 2"     1.00 [depends on who you ask]  Expressions like "A is X" can be interpreted as degrees of truth, e.g., "Drew is TALL" = 0.38.

http://www.cs.cmu.edu/Groups/AI/html/faqs/ai/fuzzy/part1/faq-doc-2.html

Humans have the incredible ability to communicate skills simply and accurately by using vague linguistic rules. For example, medium thickness, small amount, very close. Conventional logic is inadequate for processing such rules.

When considering linguistic terms such as “far” and “close” or “gently” and “firmly”, a human being is able to place vague boundaries on those terms and allow a value to be associated with a term to a matter of degree.

Fuzzy Logic, invented by a man named Lotfi Zadeh in the mid-sixties, enables a computer to reason about linguistic terms and rules in a way similar to humans. Concepts like “far” or “slightly” are not represented by discrete intervals, but by fuzzy sets, enabling values to be assigned to sets to a matter of a degree – a process called fuzzification. Using fuzzified values computers are able to interpret linguistic rules and produce an output that may remain fuzzy or – more commonly, especially in video games – can be defuzzified to provide a crisp value. This is known as fuzzy rule based inference, and is one of the most popular uses of fuzzy logic. [See picture, pg 417 – programming game ai by example]

crisp sets

Crisp sets have clearly defined boundaries: An object (sometimes called an element) either completely belongs to a set or it doesnt. This is fine for many problems since many objects can be precisely classified. The domain of all elements a set belongs to is called the universe of discource. [see picture – p417]

Using mathematical notation these sets can be written as:

Odd = {1,3,5,7,9,11,13,15}
Even = {2,4,6,8,10,12,14}

As is evident, the degree of membership of a number to a crisp set is either true or false, 1 or 0. The number 5 is 100 percent odd and 0 percent even. In classical set theory all the integers are black and white in this way – they are members of one set to a degree of 1 and to the other to a degree of 0. It's also worth highlighting that an element can be contained in more than one crisp set. For example, the integer 3 is a member of the set of odd numbers, the set of prime numbers, and the set of all numbers less than 5. But in all these sets its degree of membership is 1.

Set Operators

There are a number of operations that can be performed on sets. The most common are union, intersection and complement.

The union of two sets is the set that contains all the elements from both sets. The union operator is usually written using the symbol [insert symbol]. Given the two sets A = {1,2,3,4} and B={3,5,7}, the union of A and B can be written as:

A[SYMBOL]B = {1,2,3,4,5,6,7}

The union of 2 sets is equivalent to ORing the the sets together – a given element is in one OR the other.

The intersection of two sets, written using the symbol [SYMBOL], is the set containing all the elements present in both sets. Using the sets A and B from above, their intersection is written as:

A[SYMBOL]B = {3}

The intersection of two sets is equivalent to ANDing the sets together. Using our two sets above there is only one element that is in set A AND in set B, making the intersection of sets A and B {3}.

The complement of a set is the set containing all the elements in the universe of discourse not present in the set. In other words, it is the inverse of the set. Lets say the universe of discourse of A and B is A[SYMBOL]B as given in equation(above) then A's complement is B, and B's complement is A. The complement operator is usually written using the ' symbol, although some times it is denoted by a bar across the top of the sets name.

Fuzzy Sets

Crisp sets are useful but problematic in many situations. For instance, lets examine the universe of discourse of all IQ's, and lets define sets for Dumb, Average and Clever like so:

Dumb = {70 . . .89}

Average = {90 . . .109}

Clever = {110. . . 129}

A graphical way of showing these crisp sets is shown below. Note how the degree of membership of an element in any of the sets can be either 1 or 0.

More still to come

No comments: