Module: membership

skfuzzy.membership : fuzzy membership function generators

skfuzzy.membership.dsigmf(x, b1, c1, b2, c2) Difference of two fuzzy sigmoid membership functions.
skfuzzy.membership.gauss2mf(x, mean1, ...) Gaussian fuzzy membership function of two combined Gaussians.
skfuzzy.membership.gaussmf(x, mean, sigma) Gaussian fuzzy membership function.
skfuzzy.membership.gbellmf(x, a, b, c) Generalized Bell function fuzzy membership generator.
skfuzzy.membership.piecemf(x, abc) Piecewise linear membership function (particularly used in FIRE filters).
skfuzzy.membership.pimf(x, a, b, c, d) Pi-function fuzzy membership generator.
skfuzzy.membership.psigmf(x, b1, c1, b2, c2) Product of two sigmoid membership functions.
skfuzzy.membership.sigmf(x, b, c) The basic sigmoid membership function generator.
skfuzzy.membership.smf(x, a, b) S-function fuzzy membership generator.
skfuzzy.membership.trapmf(x, abcd) Trapezoidal membership function generator.
skfuzzy.membership.trimf(x, abc) Triangular membership function generator.
skfuzzy.membership.zmf(x, a, b) Z-function fuzzy membership generator.

dsigmf

skfuzzy.membership.dsigmf(x, b1, c1, b2, c2)[source]

Difference of two fuzzy sigmoid membership functions.

Parameters:

x : 1d array

Independent variable.

b1 : float

Midpoint of first sigmoid; f1(b1) = 0.5

c1 : float

Width and sign of first sigmoid.

b2 : float

Midpoint of second sigmoid; f2(b2) = 0.5

c2 : float

Width and sign of second sigmoid.

Returns:

y : 1d array

Generated sigmoid values, defined as

y = f1 - f2 f1(x) = 1 / (1. + exp[- c1 * (x - b1)]) f2(x) = 1 / (1. + exp[- c2 * (x - b2)])

gauss2mf

skfuzzy.membership.gauss2mf(x, mean1, sigma1, mean2, sigma2)[source]

Gaussian fuzzy membership function of two combined Gaussians.

Parameters:

x : 1d array or iterable

Independent variable.

mean1 : float

Gaussian parameter for center (mean) value of left-side Gaussian. Note mean1 <= mean2 reqiured.

sigma1 : float

Standard deviation of left Gaussian.

mean2 : float

Gaussian parameter for center (mean) value of right-side Gaussian. Note mean2 >= mean1 required.

sigma2 : float

Standard deviation of right Gaussian.

Returns:

y : 1d array

Membership function with left side up to mean1 defined by the first Gaussian, and the right side above mean2 defined by the second. In the range mean1 <= x <= mean2 the function has value = 1.

gaussmf

skfuzzy.membership.gaussmf(x, mean, sigma)[source]

Gaussian fuzzy membership function.

Parameters:

x : 1d array or iterable

Independent variable.

mean : float

Gaussian parameter for center (mean) value.

sigma : float

Gaussian parameter for standard deviation.

Returns:

y : 1d array

Gaussian membership function for x

gbellmf

skfuzzy.membership.gbellmf(x, a, b, c)[source]

Generalized Bell function fuzzy membership generator.

Parameters:

x : 1d array

Independent variable.

a : float

Bell function parameter controlling width. See Note for definition.

b : float

Bell function parameter controlling center. See Note for definition.

c : float

Bell function parameter controlling slope. See Note for definition.

Returns:

y : 1d array

Generalized Bell fuzzy membership function.

Notes

Definition of Generalized Bell function is:

y(x) = 1 / (1 + abs([x - c] / a) ** [2 * b])

piecemf

skfuzzy.membership.piecemf(x, abc)[source]

Piecewise linear membership function (particularly used in FIRE filters).

Parameters:

x : 1d array

Independent variable vector.

abc : 1d array, length 3

Defines the piecewise function. Important: if abc = [a, b, c] then a <= b <= c is REQUIRED!

Returns:

y : 1d array

Piecewise fuzzy membership function for x.

Notes

Piecewise definition:
y = 0, min(x) <= x <= a y = b(x - a)/c(b - a), a <= x <= b y = x/c, b <= x <= c

pimf

skfuzzy.membership.pimf(x, a, b, c, d)[source]

Pi-function fuzzy membership generator.

Parameters:

x : 1d array

Independent variable.

a : float

Left ‘foot’, where the function begins to climb from zero.

b : float

Left ‘ceiling’, where the function levels off at 1.

c : float

Right ‘ceiling’, where the function begins falling from 1.

d : float

Right ‘foot’, where the function reattains zero.

Returns:

y : 1d array

Pi-function.

Notes

This is equivalently a product of smf and zmf.

psigmf

skfuzzy.membership.psigmf(x, b1, c1, b2, c2)[source]

Product of two sigmoid membership functions.

Parameters:

x : 1d array

Data vector for independent variable.

b1 : float

Offset or bias for the first sigmoid. This is the center value of the sigmoid, where it equals 1/2.

c1 : float

Controls ‘width’ of the first sigmoidal region about b1 (magnitude), and also which side of the function is open (sign). A positive value of c1 means the left side approaches zero while the right side approaches one; a negative value of c1 means the opposite.

b2 : float

Offset or bias for the second sigmoid. This is the center value of the sigmoid, where it equals 1/2.

c2 : float

Controls ‘width’ of the second sigmoidal region about b2 (magnitude), and also which side of the function is open (sign). A positive value of c2 means the left side approaches zero while the right side approaches one; a negative value of c2 means the opposite.

Returns:

y : 1d array

Generated sigmoid values, defined as

y = f1(x) * f2(x)

f1(x) = 1 / (1. + exp[- c1 * (x - b1)]) f2(x) = 1 / (1. + exp[- c2 * (x - b2)])

Notes

For a smoothed rect-like function, c2 < 0 < c1. For its inverse (zero in middle, one at edges) c1 < 0 < c2.

sigmf

skfuzzy.membership.sigmf(x, b, c)[source]

The basic sigmoid membership function generator.

Parameters:

x : 1d array

Data vector for independent variable.

b : float

Offset or bias. This is the center value of the sigmoid, where it equals 1/2.

c : float

Controls ‘width’ of the sigmoidal region about b (magnitude); also which side of the function is open (sign). A positive value of a means the left side approaches 0.0 while the right side approaches 1.; a negative value of c means the opposite.

Returns:

y : 1d array

Generated sigmoid values, defined as y = 1 / (1. + exp[- c * (x - b)])

Notes

These are the same values, provided separately and in the opposite order compared to the publicly available MathWorks’ Fuzzy Logic Toolbox documentation. Pay close attention to above docstring!

smf

skfuzzy.membership.smf(x, a, b)[source]

S-function fuzzy membership generator.

Parameters:

x : 1d array

Independent variable.

a : float

‘foot’, where the function begins to climb from zero.

b : float

‘ceiling’, where the function levels off at 1.

Returns:

y : 1d array

S-function.

Notes

Named such because of its S-like shape.

trapmf

skfuzzy.membership.trapmf(x, abcd)[source]

Trapezoidal membership function generator.

Parameters:

x : 1d array

Independent variable.

abcd : 1d array, length 4

Four-element vector. Ensure a <= b <= c <= d.

Returns:

y : 1d array

Trapezoidal membership function.

trimf

skfuzzy.membership.trimf(x, abc)[source]

Triangular membership function generator.

Parameters:

x : 1d array

Independent variable.

abc : 1d array, length 3

Three-element vector controlling shape of triangular function. Requires a <= b <= c.

Returns:

y : 1d array

Triangular membership function.

zmf

skfuzzy.membership.zmf(x, a, b)[source]

Z-function fuzzy membership generator.

Parameters:

x : 1d array

Independent variable.

a : float

‘ceiling’, where the function begins falling from 1.

b : float

‘foot’, where the function reattains zero.

Returns:

y : 1d array

Z-function.

Notes

Named such because of its Z-like shape.