Linear Z-shaped¶
The Linear Z-shaped Membership Function (LinZShapedMF) is a type of membership function in fuzzy logic that represents a smooth linear transition from a full degree of membership (1.0) to zero. Its shape is ideal for modeling concepts like "cold" or "low," where membership is high up to a certain point and then decreases linearly to zero.
The formula for the LinZShapedMF is a piecewise linear function:
$$ \mu(x) = \begin{array}{ll} 1, & x \le a \\[6pt] \frac{b - x}{b - a}, & a < x < b \\[6pt] 0, & x \ge b \end{array} $$
Where $\mu(x)$ is the degree of membership of element $x$ in the fuzzy set.
The function is defined by two parameters that delimit the linear transition region:
a(Left Shoulder): The point where the membership value begins to transition from 1.0. For input values less than or equal toa, the membership is always 1.0.b(Right Foot): The point where the membership value reaches and stays at zero. For input values greater than or equal tob, the membership is always 0.0.
It is crucial that the parameter a is less than b for the linear transition to occur correctly.
Partial Derivatives (Gradients)¶
The partial derivatives are essential for optimizing the parameters a and b in adaptive fuzzy systems.
Derivative with respect to `a`
$$\frac{\partial \mu}{\partial a} = \frac{b - x}{(b - a)^2}$$
Derivative with respect to `b`
$$\frac{\partial \mu}{\partial b} = -\frac{x - a}{(b - a)^2}$$
Python Example¶
import numpy as np
import matplotlib.pyplot as plt
from anfis_toolbox.membership import LinZShapedMF
mf = LinZShapedMF(a=15, b=35)
x = np.linspace(0, 50, 100)
y = mf.forward(x)
plt.plot(x, y)
plt.show()
Visualization¶
Below is a comprehensive visualization showing how the LinZShapedMF shape changes with different parameter combinations.