Membership functions — turning "a bit warm" into a number
Instead of cutting the boundary with a single line, express how well a value matches a label as a membership degree between 0 and 1.
The temperature labels overlap slightly with each other. At 26°C, for instance, a single value can belong to several labels at once, like "comfortable 0.50, hot 0.25."
Terminology — membership function vs membership degree
This chapter uses two terms with distinct meanings.
- Membership function: the function itself that takes an input value
xand returns its compatibility with a label as a number between 0 and 1. It has a shape such as triangular or trapezoidal. - Membership degree: the output value that the function returns for a particular
x. For example, in "comfortable(26) = 0.50," the right-hand side 0.50 is the membership degree.
In short, "a membership function returns a membership degree" and "a membership degree is the output of that function." We follow this distinction throughout the rest of the course.
Choosing a function shape — why triangles and trapezoids?
Membership functions come in many shapes: Gaussian (a smooth bell curve), sigmoidal (an S-shape rising on one side), triangular, trapezoidal, and so on. We use only triangles and trapezoids in this course because they offer three concrete advantages for beginners.
- Few parameters: a triangle is fixed by 3 points, a trapezoid by 4. Designing them is easy.
- Easy hand calculation: each piece is a straight line, so you can compute membership degrees without a calculator.
- Readable intervals: the apex and the shoulder positions directly express "the best fit" and "the saturation region."
When continuous differentiability matters (for example, when plugging the controller into adaptive control or optimization), Gaussian functions are sometimes preferred. Within the scope of this course the accuracy difference is negligible, so we keep things simple with triangles and trapezoids.
Prepare just three temperature labels
Throughout this course we handle temperature with three labels: cold / comfortable / hot. The functions are just these three.
| Label | Function | Meaning |
|---|---|---|
| Cold | trapmf(x, 16, 16, 19, 23) | Solidly cold between 16–19°C, gradually weakening toward 23°C. |
| Comfortable | trimf(x, 20, 24, 28) | Most comfortable at 24°C, weakening as you move away in either direction. |
| Hot | trapmf(x, 25, 29, 34, 34) | Gradually hotter above 25°C, solidly hot from 29°C onward. |
For example, at 26°C, comfortable sits on the right slope and hot sits on the left slope.
comfortable(26) = (28 - 26) / (28 - 24) = 0.50
hot(26) = (26 - 25) / (29 - 25) = 0.25
So 26°C can be described as "both comfortable and a little bit hot." This is the fundamental difference from a 0/1 threshold.
Exercise 2-1 — Compute temperature membership
Temperature labels: cold = trap(16,16,19,23), comfortable = tri(20,24,28), hot = trap(25,29,34,34).
Q1. For the comfortable triangle tri(20,24,28), what is the membership degree at 22°C?
22°C sits on the left slope, so (22-20)/(24-20) = 0.50.
Q2. For the hot trapezoid trap(25,29,34,34), what is the membership degree at 26°C?
26°C is in the rising section, so (26-25)/(29-25) = 0.25.
Q3. For the comfortable triangle tri(20,24,28), what is the membership degree at 27°C?
27°C sits on the right slope, so (28-27)/(28-24) = 0.25.
Humidity labels overlap in the same way
We also keep three labels for humidity: dry / normal / humid.
| Label | Function | Example |
|---|---|---|
| Dry | trapmf(x, 20, 20, 30, 45) | At 40%, (45-40)/(45-30) = 0.33 |
| Normal | trimf(x, 35, 55, 75) | At 68%, (75-68)/(75-55) = 0.35 |
| Humid | trapmf(x, 60, 75, 90, 90) | At 68%, (68-60)/(75-60) = 0.53 |
At 68% we get "normal 0.35, humid 0.53." Rather than committing to just one label, the value holds both a little, so the rules in the next chapter can fire simultaneously.
Exercise 2-2 — Compute humidity membership
Humidity labels: dry = trap(20,20,30,45), normal = tri(35,55,75), humid = trap(60,75,90,90).
Q1. For the humid trapezoid trap(60,75,90,90), what is the membership degree at 68%?
68% is in the rising section, so (68-60)/(75-60) = 8/15 ≈ 0.53.
Q2. For the dry trapezoid trap(20,20,30,45), what is the membership degree at 40%?
40% sits on the right slope, so (45-40)/(45-30) = 5/15 ≈ 0.33.
Membership degrees are not probabilities
The 0.53 here is not "a 53% probability that it is 68%." It has exactly one meaning: how well 68% fits the label 'humid.' That is why comfortable and hot, or normal and humid, can both partially hold at the same time without contradiction.
In fuzzy control, we do not erase ambiguity — we pass ambiguity forward as numbers.
Membership degrees alone do not control — bridge to Chapter 3
Membership degrees only tell us "how well an input fits a label." They do not yet provide a mechanism to decide the output (what fan percentage?). For instance, even if at 26°C and 68% we obtain "comfortable 0.50, hot 0.25, normal 0.35, humid 0.53," that alone does not yet say whether to run the fan low or high.
Chapter 3 therefore introduces IF-THEN rules that derive output labels (low / medium / high fan) from input membership degrees. Membership degrees are the raw material handed to the rules; the rules are what combine that material into claims about the output. This is the division of labor we adopt going forward.