fuzzymath
¶Fuzzy mathematics subpackage, containing essential mathematical operations for fuzzy sets and universe variables.
skfuzzy.fuzzymath.cartadd (x, y) |
Cartesian addition of fuzzy membership vectors using the algebraic method. |
skfuzzy.fuzzymath.cartprod (x, y) |
Cartesian product of two fuzzy membership vectors. |
skfuzzy.fuzzymath.classic_relation (a, b) |
Determine the classic relation matrix, R , between two fuzzy sets. |
skfuzzy.fuzzymath.continuous_to_discrete (a, ...) |
Converts a continuous-time system to its equivalent discrete-time version. |
skfuzzy.fuzzymath.contrast (arr[, amount, ...]) |
General contrast booster or diffuser of normalized array-like data. |
skfuzzy.fuzzymath.fuzzy_add (x, a, y, b) |
Add fuzzy set a to fuzzy set b . |
skfuzzy.fuzzymath.fuzzy_and (x, mfx, y, mfy) |
Fuzzy AND operator, a.k.a. |
skfuzzy.fuzzymath.fuzzy_compare (q) |
Determine the comparison matrix, c , based on the fuzzy pairwise comparison matrix, q , using Shimura’s special relativity formula. |
skfuzzy.fuzzymath.fuzzy_div (x, a, y, b) |
Divide fuzzy set b into fuzzy set a . |
skfuzzy.fuzzymath.fuzzy_min (x, a, y, b) |
Find minimum between fuzzy set a fuzzy set b . |
skfuzzy.fuzzymath.fuzzy_mult (x, a, y, b) |
Multiplies fuzzy set a and fuzzy set b . |
skfuzzy.fuzzymath.fuzzy_not (mfx) |
Fuzzy NOT operator, a.k.a. |
skfuzzy.fuzzymath.fuzzy_or (x, mfx, y, mfy) |
Fuzzy OR operator, a.k.a. |
skfuzzy.fuzzymath.fuzzy_similarity (ai, b[, mode]) |
The fuzzy similarity between set ai and observation set b . |
skfuzzy.fuzzymath.fuzzy_sub (x, a, y, b) |
Subtract fuzzy set b from fuzzy set a . |
skfuzzy.fuzzymath.inner_product (a, b) |
Inner product (dot product) of two fuzzy sets. |
skfuzzy.fuzzymath.interp10 (x) |
Utility function which conducts linear interpolation of any rank-1 array. |
skfuzzy.fuzzymath.interp_membership (x, xmf, xx) |
Find the degree of membership u(xx) for a given value of x = xx . |
skfuzzy.fuzzymath.interp_universe (x, xmf, y) |
Find interpolated universe value(s) for a given fuzzy membership value. |
skfuzzy.fuzzymath.maxmin_composition (s, r) |
The max-min composition t of two fuzzy relation matrices. |
skfuzzy.fuzzymath.maxprod_composition (s, r) |
The max-product composition t of two fuzzy relation matrices. |
skfuzzy.fuzzymath.modus_ponens (a, b, ap[, c]) |
Generalized modus ponens deduction to make approximate reasoning in a rules-base system. |
skfuzzy.fuzzymath.outer_product (a, b) |
Outer product of two fuzzy sets. |
skfuzzy.fuzzymath.partial_dmf (x, mf_name, ...) |
Calculate the partial derivative of a specified membership function. |
skfuzzy.fuzzymath.relation_min (a, b) |
Determine fuzzy relation matrix R using Mamdani implication for the fuzzy antecedent a and consequent b inputs. |
skfuzzy.fuzzymath.relation_product (a, b) |
Determine the fuzzy relation matrix, R , using product implication for the fuzzy antecedent a and the fuzzy consequent b . |
skfuzzy.fuzzymath.sigmoid (x, power[, split]) |
Intensify grayscale values in an array using a sigmoid function. |
skfuzzy.fuzzymath.
cartadd
(x, y)[source]¶Cartesian addition of fuzzy membership vectors using the algebraic method.
Parameters: | x : 1D array or iterable
y : 1D array or iterable
|
---|---|
Returns: | z : 2D array
|
skfuzzy.fuzzymath.
cartprod
(x, y)[source]¶Cartesian product of two fuzzy membership vectors. Uses min()
.
Parameters: | x : 1D array or iterable
y : 1D array or iterable
|
---|---|
Returns: | z : 2D array
|
skfuzzy.fuzzymath.
classic_relation
(a, b)[source]¶Determine the classic relation matrix, R
, between two fuzzy sets.
Parameters: | a : 1D array or iterable
b : 1D array or iterable
|
---|---|
Returns: | R : 2D array
|
Notes
The classic relation is defined as:
r = [a x b] U [(1 - a) x ones(1, N)],
where x
represents a cartesian product and N
is len(b
).
skfuzzy.fuzzymath.
continuous_to_discrete
(a, b, sampling_rate)[source]¶Converts a continuous-time system to its equivalent discrete-time version.
Parameters: | a : (N, N) array of floats
b : (N,) or (N, 1) array of floats
sampling_rate : float
|
---|---|
Returns: | phi : (N, N) array of floats
gamma : (N,) or (N, 1) array of floats
|
skfuzzy.fuzzymath.
contrast
(arr, amount=0.2, split=0.5, normalize=True)[source]¶General contrast booster or diffuser of normalized array-like data.
Parameters: | arr : ndarray
amount : float or length-2 iterable of floats
split : float
normalize : bool, default True
|
---|---|
Returns: | focused : ndarray
|
See also
Notes
The result of this algorithm is like applying a Curves adjustment in the GIMP or Photoshop.
Algorithm for curves adjustment at a given pixel, x, is given by:
| split * (x/split)^below, 0 <= x <= split
y(x) = |
| 1 - (1-split) * ((1-x) / (1-split))^above, split < x <= 1.0
skfuzzy.fuzzymath.
fuzzy_add
(x, a, y, b)[source]¶Add fuzzy set a
to fuzzy set b
.
Parameters: | x : 1d array, length N
a : 1d array, length N
y : 1d array, length M
b : 1d array, length M
|
---|---|
Returns: | z : 1d array
mfz : 1d array
|
Notes
Uses Zadeh’s Extension Principle as described in Ross, Fuzzy Logic with Engineering Applications (2010), pp. 414, Eq. 12.17.
If these results are unexpected and your membership functions are convex,
consider trying the skfuzzy.dsw_*
functions for fuzzy mathematics
using interval arithmetic via the restricted Dong, Shah, and Wong method.
skfuzzy.fuzzymath.
fuzzy_and
(x, mfx, y, mfy)[source]¶Fuzzy AND operator, a.k.a. the intersection of two fuzzy sets.
Parameters: | x : 1d array
mfx : 1d array
y : 1d array
mfy : 1d array
|
---|---|
Returns: | z : 1d array
mfz : 1d array
|
skfuzzy.fuzzymath.
fuzzy_div
(x, a, y, b)[source]¶Divide fuzzy set b
into fuzzy set a
.
Parameters: | x : 1d array, length N
a : 1d array, length N
y : 1d array, length M
b : 1d array, length M
|
---|---|
Returns: | z : 1d array
mfz : 1d array
|
Notes
Uses Zadeh’s Extension Principle from Ross, Fuzzy Logic w/Engineering Applications, (2010), pp.414, Eq. 12.17.
If these results are unexpected and your membership functions are convex,
consider trying the skfuzzy.dsw_*
functions for fuzzy mathematics
using interval arithmetic via the restricted Dong, Shah, and Wong method.
skfuzzy.fuzzymath.
fuzzy_min
(x, a, y, b)[source]¶Find minimum between fuzzy set a
fuzzy set b
.
Parameters: | x : 1d array, length N
a : 1d array, length N
y : 1d array, length M
b : 1d array, length M
|
---|---|
Returns: | z : 1d array
mfz : 1d array
|
Notes
Uses Zadeh’s Extension Principle from Ross, Fuzzy Logic w/Engineering Applications, (2010), pp.414, Eq. 12.17.
If these results are unexpected and your membership functions are convex,
consider trying the skfuzzy.dsw_*
functions for fuzzy mathematics
using interval arithmetic via the restricted Dong, Shah, and Wong method.
skfuzzy.fuzzymath.
fuzzy_mult
(x, a, y, b)[source]¶Multiplies fuzzy set a
and fuzzy set b
.
Parameters: | x : 1d array, length N
A : 1d array, length N
y : 1d array, length M
b : 1d array, length M
|
---|---|
Returns: | z : 1d array
mfz : 1d array
|
Notes
Uses Zadeh’s Extension Principle from Ross, Fuzzy Logic w/Engineering Applications, (2010), pp.414, Eq. 12.17.
If these results are unexpected and your membership functions are convex,
consider trying the skfuzzy.dsw_*
functions for fuzzy mathematics
using interval arithmetic via the restricted Dong, Shah, and Wong method.
skfuzzy.fuzzymath.
fuzzy_not
(mfx)[source]¶Fuzzy NOT operator, a.k.a. complement of a fuzzy set.
Parameters: | mfx : 1d array
|
---|---|
Returns: | mfz : 1d array
|
Notes
This operation does not require a universe variable, because the complement is defined for a single set. The output remains defined on the same universe.
skfuzzy.fuzzymath.
fuzzy_or
(x, mfx, y, mfy)[source]¶Fuzzy OR operator, a.k.a. union of two fuzzy sets.
Parameters: | x : 1d array
mfx : 1d array
y : 1d array
mfy : 1d array
|
---|---|
Returns: | z : 1d array
mfz : 1d array
|
skfuzzy.fuzzymath.
fuzzy_similarity
(ai, b, mode='min')[source]¶The fuzzy similarity between set ai
and observation set b
.
Parameters: | ai : 1d array
b : 1d array
mode : string
|
---|---|
Returns: | s : float
|
skfuzzy.fuzzymath.
fuzzy_sub
(x, a, y, b)[source]¶Subtract fuzzy set b
from fuzzy set a
.
Parameters: | x : 1d array, length N
A : 1d array, length N
y : 1d array, length M
b : 1d array, length M
|
---|---|
Returns: | z : 1d array
mfz : 1d array
|
Notes
Uses Zadeh’s Extension Principle from Ross, Fuzzy Logic w/Engineering Applications, (2010), pp.414, Eq. 12.17.
If these results are unexpected and your membership functions are convex,
consider trying the skfuzzy.dsw_*
functions for fuzzy mathematics
using interval arithmetic via the restricted Dong, Shah, and Wong method.
skfuzzy.fuzzymath.
interp_membership
(x, xmf, xx)[source]¶Find the degree of membership u(xx)
for a given value of x = xx
.
Parameters: | x : 1d array
xmf : 1d array
xx : float
|
---|---|
Returns: | xxmf : float
|
Notes
For use in Fuzzy Logic, where an interpolated discrete membership function
u(x) for discrete values of x on the universe of x
is given. Then,
consider a new value x = xx, which does not correspond to any discrete
values of x
. This function computes the membership value u(xx)
corresponding to the value xx
using linear interpolation.
skfuzzy.fuzzymath.
interp_universe
(x, xmf, y)[source]¶Find interpolated universe value(s) for a given fuzzy membership value.
Parameters: | x : 1d array
xmf : 1d array
y : float
|
---|---|
Returns: | xx : list
|
Notes
For use in Fuzzy Logic, where a membership function level y
is given.
Consider there is some value (or set of values) xx
for which
u(xx) == y
is true, though xx
may not correspond to any discrete
values on x
. This function computes the value (or values) of xx
such that u(xx) == y
using linear interpolation.
skfuzzy.fuzzymath.
modus_ponens
(a, b, ap, c=None)[source]¶Generalized modus ponens deduction to make approximate reasoning in a rules-base system.
Parameters: | a : 1d array
b : 1d array
ap : 1d array
c : 1d array, OPTIONAL
|
---|---|
Returns: | R : 2d array
bp : 1d array
|
skfuzzy.fuzzymath.
partial_dmf
(x, mf_name, mf_parameter_dict, partial_parameter)[source]¶Calculate the partial derivative of a specified membership function.
Parameters: | x : float
mf_name : string
mf_parameter_dict : dict
partial_parameter : string
|
---|---|
Returns: | d : float
|
Notes
Partial derivatives of fuzzy membership functions are only meaningful for continuous functions. Triangular, trapezoidal designs have no partial derivatives to calculate. The following
skfuzzy.fuzzymath.
relation_min
(a, b)[source]¶Determine fuzzy relation matrix R
using Mamdani implication for the
fuzzy antecedent a
and consequent b
inputs.
Parameters: | a : 1d array
b : 1d array
|
---|---|
Returns: | R : 2d array
|
skfuzzy.fuzzymath.
relation_product
(a, b)[source]¶Determine the fuzzy relation matrix, R
, using product implication for
the fuzzy antecedent a
and the fuzzy consequent b
.
Parameters: | a : 1d array
b : 1d array
|
---|---|
Returns: | R : 2d array
|
skfuzzy.fuzzymath.
sigmoid
(x, power, split=0.5)[source]¶Intensify grayscale values in an array using a sigmoid function.
Parameters: | x : ndarray
p : float
split : float
|
---|---|
Returns: | y : ndarray, same size as x
|
See also
Notes
The sigmoid used herein is defined as:
y = 1 / (1 + exp(- exp(- power * (x-split))))