Fuzzy
Fuzzy
Fuzzy logic
Output:
This is the real-world setup: two things affect the tip — food and service. You rate them
(like 7/10), and the system tells you how much to tip.
Step 2: Fuzzification
Example Input:
Let’s assume:
● Food = 7
● Service = 9
We now calculate how much each input belongs to each fuzzy set using simple triangle math.
Food = 7
● Bad → Ends at 5 → So 7 = 0
● Decent:
○ Use formula:
If x ≥ 5 → slope down:
Decent=(7−x)/7−5)=(7-7)/(7-5)=0
● Good:
○ Use formula:
Good=(x−5)/(10−5)=(7−5)/(10-5)=0.4
So:
● Bad = 0
● Decent = 0
● Good = 0.4
Service = 9
● Poor → Ends at 5 → 0
● Average → Ends at 7 → 0
● Excellent:
○ Use formula:
Excellent=(9−5)/(10−5)=0.8
So:
● Poor = 0
● Average = 0
● Excellent = 0.8
Step 3: Define Fuzzy Rules
Step 4: Rule Evaluation (Inference)
We now apply the fuzzy rules using fuzzy logic (AND = min, OR = max):
● Service poor = 0
● Food bad = 0
→ Max(0, 0) = 0 → So tip is low = 0