Skip to content
Tutorials Center
My learning

Topics

Lesson 15 of 36 ยท Fuzzy Inference

Fuzzification

Learn fuzzification, the first step of fuzzy inference: map measured numbers to membership degrees with singleton and non-singleton fuzzifiers, and handle out-of-range input in Python.

Sensors, forms and databases give you plain numbers: 23.4 degrees, a score of 7, an income of 41 000. Rules, however, talk about words such as warm, good and medium. Fuzzification is the bridge: it converts each crisp input number into a set of membership degrees, one per linguistic term of that input. It is the first box after the input in the pipeline from Anatomy of a Fuzzy System, and it is simple but easy to get subtly wrong.

Singleton fuzzification

The standard method treats the measurement as exact. Given the input x0, the degree of every term is just its membership function evaluated at x0:

TEXT
degree(term) = mu_term(x0)

Formally this treats the input as a fuzzy singleton: a set that is 1 at x0 and 0 everywhere else. It is the cheapest option and the one used by almost every toolbox and product.

Here is a small reusable Variable class that stores the terms of one input and fuzzifies a reading. We will reuse the same idea in later lessons.

Python A reusable fuzzifier

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

At 45 km/h the speed is slow to 0.38 and medium to 0.5. A reading like 60 is only medium, and 110 is only fast. Between the term centres, two terms are active at once, which is exactly what produces smooth behaviour downstream.

What fuzzification gives the rest of the system

The output of fuzzification is a small table of numbers, one per input term. Rules then look up the degrees they need. In a system with two inputs of three terms each, fuzzification produces six numbers. The cost is tiny (a few evaluations per input), which is one reason fuzzy controllers run on very modest hardware.

flowchart LR
    X1["speed = 45"] --> F1["slow 0.40<br/>medium 0.50<br/>fast 0.00"]
    X2["distance = 18"] --> F2["near = degree<br/>far = degree"]
    F1 --> R["Rule base"]
    F2 --> R

Each input becomes a handful of degrees; the rule base reads them.

Non-singleton fuzzification

Measurements are noisy. A sensor reading of 45 might really mean "about 45, give or take 5". Non-singleton fuzzification models this by turning the input into a fuzzy number mu_x centred on the reading (often a Gaussian or triangle) instead of a spike. The degree of a term is then the best overlap between the input set and the term:

TEXT
degree(term) = max over x of  min( mu_input(x), mu_term(x) )

(Using the min t-norm; this is the sup-min composition from Fuzzy Relations and Composition.) The effect is that a noisy input produces slightly higher degrees for terms near the reading, so small measurement errors cannot flip the behaviour.

Python Singleton versus non-singleton fuzzification

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

With an uncertain input, "fast" is no longer exactly 0, because the cloud around 45 reaches into the region where "fast" starts to be true. Non-singleton systems are more robust to noise but cost more, so they are used only when sensor noise is significant.

Practical details

Several details decide whether a fuzzifier is reliable.

  • Range checking. Sensors drift outside the range you designed for. Either clip the input to the universe (np.clip(x, low, high)), which keeps shoulders at their full degree, or reject the reading as faulty. Never let an unexpected value silently produce all-zero degrees.
  • Normalisation. Many designs scale each input to a standard range such as [-1, 1], so the same membership shapes work for different units. Remember to scale the output back.
  • Units. Convert once, at the input, and keep a unit comment next to every variable. Mixing degrees Celsius and Fahrenheit is a classic bug.
  • Discretisation. Software often samples the universe on a grid (like np.linspace) and looks up the nearest sample. Use a fine grid or compute the function directly to avoid staircase errors.
Python Clipping out-of-range input

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

For the reading -15, which is below the sensor range, the unclipped formula returns 1.0 here only because the shoulder is defined as 1 on the left; for a non-shoulder term the same reading would give 0 and, if no other term covers it, no rule would fire. Clipping first makes the behaviour predictable for every term.

Check coverage. After designing the terms of an input, evaluate the fuzzifier at many points of the universe and confirm that the sum of degrees never drops to 0. A gap in coverage is a silent bug: the rules simply do not fire there.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does singleton fuzzification compute?

    Each term's degree is mu_term(x0), as if the input were an exact spike at x0.
  2. 2. When is non-singleton fuzzification useful?

    Treating the input as a fuzzy number makes the system more robust against measurement noise.
  3. 3. Which formula gives a term's degree for a fuzzy input set?

    It is the best overlap (sup-min) between the input set and the term.
  4. 4. Why clip inputs to the universe before fuzzifying?

    Out-of-range readings may fall outside every term and fire no rule; clipping keeps behaviour predictable.

Summary

  • Fuzzification converts each crisp input to degrees of membership in its terms.
  • The standard singleton fuzzifier simply evaluates each membership function at the measured value.
  • A non-singleton fuzzifier models noisy inputs as fuzzy numbers and uses the best overlap.
  • Always clip or validate input ranges, normalise consistently and confirm full coverage of the universe.

Next: Mamdani Inference