Skip to content
Tutorials Center
My learning

Topics

Lesson 10 of 36 ยท Membership Functions and Operations

Gaussian, Bell and Sigmoid Functions

Learn smooth fuzzy membership functions: Gaussian, generalized bell, sigmoid, S, Z and pi shapes, with formulas, parameter effects and runnable NumPy code.

Triangles and trapezoids have corners. At a corner the slope changes abruptly, which is fine for most rule bases but is a problem when you need a smooth, differentiable output, for example when you tune parameters with gradient descent or when a physical actuator hates sudden changes in slope. In those cases you use smooth membership functions. This lesson covers the common ones: the Gaussian, the generalized bell, the sigmoid, and the spline-based S, Z and pi shapes.

If piecewise-linear shapes are new to you, read Triangular and Trapezoidal Membership Functions first.

The Gaussian function

TEXT
mu(x) = exp( -(x - c)^2 / (2 * sigma^2) )

c is the centre (where mu = 1) and sigma controls the width. A Gaussian is symmetric, perfectly smooth, and never exactly reaches 0 (although it gets tiny quickly). Two parameters keep it simple to tune.

The generalized bell function

TEXT
mu(x) = 1 / ( 1 + | (x - c) / a |^(2b) )

Three parameters: a sets the half-width (at x = c +- a the membership is exactly 0.5), b sets how steep the sides are (larger b gives a flatter top and steeper edges, so it looks more like a trapezoid) and c is the centre. With b = 1 it is the "Cauchy" curve, with long tails.

Python Gaussian and bell shapes

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.

Compare the last two columns. With b = 1 the membership decays slowly and has fat tails; with b = 4 it stays near 1 close to the centre, then drops quickly around x = 3 and x = 7: a smooth cousin of the trapezoid. Both are exactly 0.5 at c +- a.

The sigmoid function

The sigmoid is a smooth step: it rises from 0 to 1 around a midpoint.

TEXT
mu(x) = 1 / ( 1 + exp( -a * (x - c) ) )

c is the point where the membership is 0.5, and a controls the steepness. If a is positive it is an "open right" set such as "hot" or "large"; if a is negative it is "open left", like "cold" or "small". You can also build a smooth bump by multiplying a rising sigmoid by a falling one, or by taking their difference.

Python Sigmoids as open-ended terms and as a band

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.

The sigmoid with a huge a approaches a crisp step, which shows that fuzzy sets can approximate crisp ones. Sigmoids are also the activation functions of neural networks, which is one reason they appear in neuro-fuzzy systems.

S, Z and pi shapes

Sometimes you want an S-shaped transition with a finite start and end, like a trapezoid ramp but smooth. The standard solution is a piecewise-quadratic spline:

  • S-shape (smf(x, a, b)): 0 up to a, smoothly rises to 1 at b, then 1.
  • Z-shape (zmf(x, a, b)): the mirror image, 1 up to a, falls to 0 at b.
  • Pi-shape: an S followed by a Z, giving a smooth bump with a flat top.

For the S-shape, with m = (a + b) / 2:

TEXT
0                              x <= a
2 * ((x - a) / (b - a))^2      a < x <= m
1 - 2 * ((x - b) / (b - a))^2  m < x < b
1                              x >= b
Python The S, Z and pi shapes

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.

The S-shape reaches exactly 0 and 1 at its end points (unlike the sigmoid) and has a smooth slope everywhere. At the midpoint x = 5 it equals 0.5.

Choosing between shapes

Shape Strength Weakness
Triangle / trapezoid Fast, readable, easy to tune Corners (not differentiable)
Gaussian Smooth, two parameters, easy to fit to data Never exactly 0; always symmetric
Generalized bell Control of width and edge steepness Three parameters
Sigmoid Natural for open-ended terms; neural-network link Needs a pair for a bounded term
S / Z / pi Smooth with finite support More complex formulas

In practice the shape matters far less than the position and overlap of the terms. A system with triangles and a system with Gaussians placed at the same centres usually behave very similarly. Choose the simplest shape that satisfies your needs, and spend your tuning effort on the positions.

flowchart TD
    Q{"Need a smooth,<br/>differentiable output?"} -->|"No"| T["Triangle or trapezoid"]
    Q -->|"Yes"| P{"Open-ended term?"}
    P -->|"Yes"| S["Sigmoid, S or Z shape"]
    P -->|"No, a bump"| G["Gaussian, bell or pi shape"]

A quick guide for picking a membership shape.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What does the parameter sigma control in a Gaussian membership function?

    c sets the centre, sigma sets how wide the bell is.
  2. 2. In the generalized bell function, what is the membership at x = c + a?

    At |x - c| = a the formula gives 1 / (1 + 1) = 0.5, whatever the value of b.
  3. 3. Which function suits an open-ended term such as hot, which keeps rising and stays near 1?

    A sigmoid rises from 0 and settles near 1, which matches an open-right term.
  4. 4. Which shape reaches exactly 0 and exactly 1 at finite points yet is smooth?

    The S-shape is a quadratic spline with finite support: exactly 0 before a, exactly 1 after b.
  5. 5. What usually matters most for system behaviour?

    Different shapes at the same centres usually behave alike, so positions and overlap deserve the tuning effort.

Summary

  • Smooth membership functions avoid corners and suit gradient-based tuning.
  • The Gaussian uses a centre and a width; the generalized bell adds a steepness exponent and is exactly 0.5 at c +- a.
  • The sigmoid models open-ended terms; two sigmoids can form a smooth band.
  • S, Z and pi shapes are splines with finite support that reach exactly 0 and 1.
  • Prefer the simplest shape; tune positions and overlap first.

Next: Fuzzy Complement, Union and Intersection