ex_fuzzy.fuzzy_sets.FS.membership#

FS.membership(x)[source]#

Compute membership degrees for input values.

This method calculates the membership degree(s) for the given input value(s) using the trapezoidal membership function defined by this fuzzy set’s parameters.

Parameters:

x (np.array) – Input value(s) for which to compute membership degrees. Can be a single value, list, or numpy array.

Returns:

Membership degree(s) in the range [0, 1]. Shape matches input.

Return type:

np.array

Example

>>> fs = FS("medium", [2, 3, 7, 8], [0, 10])
>>> print(fs.membership(5))    # 1.0 (in flat region)
>>> print(fs.membership(2.5)) # 0.5 (on rising slope)
>>> print(fs.membership([1, 5, 9])) # [0.0, 1.0, 0.0]