Upcoming SlideShare
×

# Fuzzy logic

703 views
604 views

Published on

AI notes

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
703
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
37
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Fuzzy logic

1. 1. fuzzy logic:Fuzzy logic is a superset of conventional (Boolean) logic that has beenextended to handle the concept of partial truth -- truth values between"completely true" and "completely false". It was introduced by Dr.LotfiZadeh of UC/Berkeley in the 1960s as a means to model the uncertaintyof natural language.Zadeh says that rather than regarding fuzzy theory as a single theory,weshould regard the process of ``fuzzification as a methodology togeneralize 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 theconcept of a subset, there is a similar strong relationship betweenfuzzylogic and fuzzy subset theory.In classical set theory, a subset U of a set S can be defined as amapping 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 exactlyone ordered pair present for each element of S. The first element oftheordered pair is an element of the set S, and the second element is anelement of the set {0, 1}. The value zero is used to representnon-membership, and the value one is used to represent membership. Thetruth or falsity of the statement x is in Uis determined by finding the ordered pair whose first element is x.Thestatement is true if the second element of the ordered pair is 1, andthestatement is false if it is 0.Similarly, a fuzzy subset F of a set S can be defined as a set oforderedpairs, each with the first element from S, and the second element fromthe interval [0,1], with exactly one ordered pair present for eachelement of S. This defines a mapping between elements of the set S andvalues in the interval [0,1]. The value zero is used to represent
2. 2. complete non-membership, the value one is used to represent completemembership, and values in between are used to represent intermediateDEGREES OF MEMBERSHIP. The set S is referred to as the UNIVERSE OFDISCOURSE for the fuzzy subset F. Frequently, the mapping is describedas a function, the MEMBERSHIP FUNCTION of F. The degree to which thestatement x is in Fis true is determined by finding the ordered pair whose first elementisx. The DEGREE OF TRUTH of the statement is the second element of theordered pair.In practice, the terms "membership function" and fuzzy subset get usedinterchangeably.Thats a lot of mathematical baggage, so heres an example. Letstalk about people and "tallness". In this case the set S (theuniverse of discourse) is the set of people. Lets define a fuzzysubset TALL, which will answer the question "to what degree is personx tall?" Zadeh describes TALL as a LINGUISTIC VARIABLE, whichrepresents our cognitive category of "tallness". To each person in theuniverse of discourse, we have to assign a degree of membership in thefuzzy subset TALL. The easiest way to do this is with a membershipfunction based on the persons height. tall(x) = { 0, if height(x) < 5 ft., (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
3. 3. --------------------------------------Billy 3 2" 0.00 [I think]Yoke 5 5" 0.21Drew 5 9" 0.38Erik 5 10" 0.42Mark 6 1" 0.54Kareem 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.Note: Membership functions used in most applications almost never haveassimple a shape as tall(x). At minimum, they tend to be trianglespointingup, and they can be much more complex than that. Also, the discussioncharacterizes membership functions as if they always are based on asingle criterion, but this isnt always the case, although it is quitecommon. One could, for example, want to have the membership functionforTALL depend on both a persons height and their age (hes tall for hisage). This is perfectly legitimate, and occasionally used in practice.Its referred to as a two-dimensional membership function, or a "fuzzyrelation". Its also possible to have even more criteria, or to havethemembership function depend on elements from two completely differentuniverses of discourse.Logic Operations:->Now that we know what a statement like "X is LOW" means in fuzzy logic,how do we interpret a statement like X is LOW and Y is HIGH or (not Z is MEDIUM)The standard definitions in fuzzy logic are: truth (not x) = 1.0 - truth (x) truth (x and y) = minimum (truth(x), truth(y)) truth (x or y) = maximum (truth(x), truth(y))Some researchers in fuzzy logic have explored the use of otherinterpretations of the AND and OR operations, but the definition fortheNOT operation seems to be safe.Note that if you plug just the values zero and one into thesedefinitions, you get the same truth tables as you would expect from
4. 4. conventional Boolean logic. This is known as the EXTENSION PRINCIPLE,which states that the classical results of Boolean logic are recoveredfrom fuzzy logic operations when all fuzzy membership grades arerestricted to the traditional set {0, 1}. This effectively establishesfuzzy subsets and logic as a true generalization of classical settheoryand logic. In fact, by this reasoning all crisp (traditional) subsetsAREfuzzy subsets of this very special type; and there is no conflictbetweenfuzzy and crisp methods.Some examples:->assume the same definition of TALL as above, and in addition,assume that we have a fuzzy subset OLD defined by the membershipfunction: old (x) = { 0, if age(x) < 18 yr. (age(x)-18 yr.)/42 yr., if 18 yr. <= age(x) <= 60 yr. 1, if age(x) > 60 yr. }And for compactness, let a = X is TALL and X is OLD b = X is TALL or X is OLD c = not (X is TALL)Then we can compute the following values.height age X is TALL X is OLD a b c----------------------------------------------------------used of fuzzy logic :->Fuzzy logic is used directly in very few applications. The Sony PalmTopapparently uses a fuzzy logic decision tree algorithm to performhandwritten (well, computer lightpen) Kanji character recognition.A fuzzy expert system:->A fuzzy expert system is an expert system that uses a collection offuzzy membership functions and rules, instead of Boolean logic, toreason about data. The rules in a fuzzy expert system are usually of aform similar to the following: if x is low and y is high then z = medium
5. 5. where x and y are input variables (names for know data values), z is anoutput variable (a name for a data value to be computed), low is amembership function (fuzzy subset) defined on x, high is a membershipfunction defined on y, and medium is a membership function defined onz.The antecedent (the rules premise) describes to what degree the ruleapplies, while the conclusion (the rules consequent) assigns amembership function to each of one or more output variables. Mosttoolsfor working with fuzzy expert systems allow more than one conclusionperrule. The set of rules in a fuzzy expert system is known as therulebaseor knowledge base.The general inference process proceeds in three (or four) steps.1. Under FUZZIFICATION, the membership functions defined on the input variables are applied to their actual values, to determine the degree of truth for each rule premise.2. Under INFERENCE, the truth value for the premise of each rule is computed, and applied to the conclusion part of each rule. Thisresults in one fuzzy subset to be assigned to each output variable for each rule. Usually only MIN or PRODUCT are used as inference rules. InMIN inferencing, the output membership function is clipped off at aheight corresponding to the rule premises computed degree of truth (fuzzy logic AND). In PRODUCT inferencing, the output membership functionis scaled by the rule premises computed degree of truth.3. Under COMPOSITION, all of the fuzzy subsets assigned to each output variable are combined together to form a single fuzzy subset for each output variable. Again, usually MAX or SUM are used. InMAX composition, the combined output fuzzy subset is constructed bytaking the pointwise maximum over all of the fuzzy subsets assignedtovariable by the inference rule (fuzzy logic OR). In SUM composition, the combined output fuzzy subset is constructed by taking the pointwisesum over all of the fuzzy subsets assigned to the output variable by the inference rule.
6. 6. 4. Finally is the (optional) DEFUZZIFICATION, which is used when it is useful to convert the fuzzy output set to a crisp number. There are more defuzzification methods than you can shake a stick at (at least 30). Two of the more common techniques are the CENTROID and MAXIMUM methods. In the CENTROID method, the crisp value of the outputvariable is computed by finding the variable value of the center of gravityof the membership function for the fuzzy value. In the MAXIMUM method,one of the variable values at which the fuzzy subset has its maximumtruth value is chosen as the crisp value for the output variable.Extended Example:Assume that the variables x, y, and z all take on values in theinterval[0,10], and that the following membership functions and rules aredefined: low(t) = 1 - ( t / 10 ) high(t) = t / 10 rule 1: if x is low and y is low then z is high rule 2: if x is low and y is high then z is low rule 3: if x is high and y is low then z is low rule 4: if x is high and y is high then z is highNotice that instead of assigning a single value to the output variablez, eachrule assigns an entire fuzzy subset (low or high).Notes:1. In this example, low(t)+high(t)=1.0 for all t. This is notrequired, but it is fairly common.2. The value of t at which low(t) is maximum is the same as the valueof t at which high(t) is minimum, and vice-versa. This is also notrequired, but fairly common.3. The same membership functions are used for all variables. Thisisnt required, and is also *not* common.
7. 7. In the fuzzification subprocess, the membership functions defined ontheinput variables are applied to their actual values, to determine thedegree of truth for each rule premise. The degree of truth for arulespremise is sometimes referred to as its ALPHA. If a rules premise hasanonzero degree of truth (if the rule applies at all...) then the ruleissaid to FIRE. For example,x y low(x) high(x) low(y) high(y) alpha1 alpha2 alpha3alpha4------------------------------------------------------------------------------0.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 0.00.00.0 3.2 1.0 0.0 0.68 0.32 0.68 0.32 0.00.00.0 6.1 1.0 0.0 0.39 0.61 0.39 0.61 0.00.00.0 10.0 1.0 0.0 0.0 1.0 0.0 1.0 0.00.03.2 0.0 0.68 0.32 1.0 0.0 0.68 0.0 0.320.06.1 0.0 0.39 0.61 1.0 0.0 0.39 0.0 0.610.010.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 1.00.03.2 3.1 0.68 0.32 0.69 0.31 0.68 0.31 0.320.313.2 3.3 0.68 0.32 0.67 0.33 0.67 0.33 0.320.3210.0 10.0 0.0 1.0 0.0 1.0 0.0 0.0 0.01.0In the inference subprocess, the truth value for the premise of eachrule iscomputed, and applied to the conclusion part of each rule. Thisresults inone fuzzy subset to be assigned to each output variable for each rule.MIN and PRODUCT are two INFERENCE METHODS or INFERENCE RULES. InMINinferencing, the output membership function is clipped off at a heightcorresponding to the rule premises computed degree of truth. This
8. 8. corresponds to the traditional interpretation of the fuzzy logic ANDoperation. In PRODUCT inferencing, the output membership function isscaled by the rule premises computed degree of truth.For example, lets look at rule 1 for x = 0.0 and y = 3.2. As shown inthetable above, the premise degree of truth works out to 0.68. For thisrule,MIN inferencing will assign z the fuzzy subset defined by themembershipfunction: rule1(z) = { z / 10, if z <= 6.8 0.68, if z >= 6.8 }For the same conditions, PRODUCT inferencing will assign z the fuzzysubsetdefined by the membership function: rule1(z) = 0.68 * high(z) = 0.068 * zNote: The terminology used here is slightly nonstandard. In mosttexts,the term "inference method" is used to mean the combination of thethingsreferred to separately here as "inference" and "composition." Thusyoull see such terms as "MAX-MIN inference" and "SUM-PRODUCTinference"in the literature. They are the combination of MAX composition and MINinference, or SUM composition and PRODUCT inference, respectively.Youll also see the reverse terms "MIN-MAX" and "PRODUCT-SUM" -- thesemean the same things as the reverse order. It seems clearer todescribethe two processes separately.In the composition subprocess, all of the fuzzy subsets assigned toeachoutput variable are combined together to form a single fuzzy subset foreachoutput variable.MAX composition and SUM composition are two COMPOSITION RULES. In MAXcomposition, the combined output fuzzy subset is constructed by takingthe pointwise maximum over all of the fuzzy subsets assigned to theoutput variable by the inference rule. In SUM composition, thecombined
9. 9. output fuzzy subset is constructed by taking the pointwise sum over allof the fuzzy subsets assigned to the output variable by the inferencerule. Note that this can result in truth values greater than one! Forthis reason, SUM composition is only used when it will be followed by adefuzzification method, such as the CENTROID method, that doesnt haveaproblem with this odd case. Otherwise SUM composition can be combinedwith normalization and is therefore a general purpose method again.For example, assume x = 0.0 and y = 3.2. MIN inferencing would assignthefollowing four fuzzy subsets to z: rule1(z) = { z / 10, if z <= 6.8 0.68, if z >= 6.8 } rule2(z) = { 0.32, if z <= 6.8 1 - z / 10, if z >= 6.8 } rule3(z) = 0.0 rule4(z) = 0.0MAX composition would result in the fuzzy subset: fuzzy(z) = { 0.32, if z <= 3.2 z / 10, if 3.2 <= z <= 6.8 0.68, if z >= 6.8 }PRODUCT inferencing would assign the following four fuzzy subsets to z: rule1(z) = 0.068 * z rule2(z) = 0.32 - 0.032 * z rule3(z) = 0.0 rule4(z) = 0.0SUM composition would result in the fuzzy subset: fuzzy(z) = 0.32 + 0.036 * zSometimes it is useful to just examine the fuzzy subsets that are theresult of the composition process, but more often, this FUZZY VALUEneedsto be converted to a single number -- a CRISP VALUE. This is what thedefuzzification subprocess does.
10. 10. fuzzy numbers and fuzzy arithmetic:->Fuzzy numbers are fuzzy subsets of the real line. They have a peak orplateau with membership grade 1, over which the members of theuniverse are completely in the set. The membership function isincreasing towards the peak and decreasing away from it.Fuzzy numbers are used very widely in fuzzy control applications. Atypicalcase is the triangular fuzzy number1.0 + + | / | / 0.5 + / | / | / 0.0 +-------------+-----+-----+-------------- | | | 5.0 7.0 9.0which is one form of the fuzzy number 7. Slope and trapezoidalfunctionsare also used, as are exponential curves similar to Gaussianprobabilitydensities.There are more defuzzification methods than you can shake a stick at.Acouple of years ago, Mizumoto did a short paper that compared about tendefuzzification methods. Two of the more common techniques are theCENTROID and MAXIMUM methods. In the CENTROID method, the crisp valueofthe output variable is computed by finding the variable value of thecenter of gravity of the membership function for the fuzzy value. IntheMAXIMUM method, one of the variable values at which the fuzzy subsethasits maximum truth value is chosen as the crisp value for the outputvariable. There are several variations of the MAXIMUM method thatdifferonly in what they do when there is more than one variable value atwhichthis maximum truth value occurs. One of these, the AVERAGE-OF-MAXIMAmethod, returns the average of the variable values at which the maximumtruth value occurs.
11. 11. For example, go back to our previous examples. Using MAX-MINinferencingand AVERAGE-OF-MAXIMA defuzzification results in a crisp value of 8.4forz. Using PRODUCT-SUM inferencing and CENTROID defuzzification resultsina crisp value of 5.6 for z, as follows.Earlier on in the FAQ, we state that all variables (including z) takeonvalues in the range [0, 10]. To compute the centroid of the functionf(x),you divide the moment of the function by the area of the function. Tocomputethe moment of f(x), you compute the integral of x*f(x) dx, and tocompute thearea of f(x), you compute the integral of f(x) dx. In this case, wewouldcompute the area as integral from 0 to 10 of (0.32+0.036*z) dz, whichis (0.32 * 10 + 0.018*100) = (3.2 + 1.8) = 5.0and the moment as the integral from 0 to 10 of (0.32*z+0.036*z*z) dz,which is (0.16 * 10 * 10 + 0.012 * 10 * 10 * 10) = (16 + 12) = 28Finally, the centroid is 28/5 or 5.6.Note: Sometimes the composition and defuzzification processes arecombined, taking advantage of mathematical relationships that simplifythe process of computing the final output variable values.The Mizumoto reference is probably "Improvement Methods of FuzzyControls", in Proceedings of the 3rd IFSA Congress, pages 60-62, 1989.================================================================Used of fuzzy expert systems :->To date, fuzzy expert systems are the most common use of fuzzy logic.They