membership | R Documentation |
A collection of functions to compute membership values for various fuzzy sets, including triangular, trapezoidal, Gaussian, generalized bell, two-parameter Gaussian, sigmoid, difference of sigmoids, product of sigmoids, Z-shaped, PI-shaped, and S-shaped membership functions. Includes a function to visualize membership functions using ggplot2. These are designed for evaluation models in mathematical modeling, compatible with fuzzy_eval
in the mathmodels
package.
tri_mf(x, params)
trap_mf(x, params)
gauss_mf(x, params)
gbell_mf(x, params)
gauss2mf(x, params)
sigmoid_mf(x, params)
dsigmoid_mf(x, params)
psigmoid_mf(x, params)
z_mf(x, params)
pi_mf(x, params)
s_mf(x, params)
plot_mf(mf, xlim = c(0, 10), main = NULL)
x |
Numeric vector, input values for which to compute membership. |
params |
Numeric vector, parameters defining the membership function:
|
mf |
Function, a membership function with fixed parameters (e.g., |
xlim |
Numeric vector of length 2, x-axis limits for plotting (default |
main |
Character, plot title (default |
These functions support evaluation models in mathematical modeling:
tri_mf
: Triangular membership, linear rise from a
to b
(peak) and fall to c
.
trap_mf
: Trapezoidal membership, linear rise from a
to b
, plateau from b
to c
, fall to d
.
gauss_mf
: Gaussian membership, bell-shaped curve centered at c
with spread sigma
.
gbell_mf
: Generalized bell membership, bell-shaped curve with width a
, shape b
, and center c
.
gauss2mf
: Two-parameter Gaussian membership, combining two Gaussians with spreads s1
, s2
and centers c1
, c2
.
sigmoid_mf
: Sigmoid membership, S-shaped curve with slope a
and inflection point b
.
dsigmoid_mf
: Difference of two sigmoids, combining slopes a1
, a2
and inflection points c1
, c2
.
psigmoid_mf
: Product of two sigmoids, combining slopes a1
, a2
and inflection points c1
, c2
.
z_mf
: Z-shaped membership, decreasing from 1 at a
to 0 at b
.
pi_mf
: PI-shaped membership, rising from a
to b
, plateau from b
to c
, falling to d
.
s_mf
: S-shaped membership, increasing from 0 at a
to 1 at b
.
plot_mf
: Plots a membership function over xlim
using ggplot2, suitable for tidyverse workflows.
Membership values can be used to construct fuzzy evaluation matrices for fuzzy_eval
.
Implemented in base R, except plot_mf
, which requires ggplot2.
For membership functions (tri_mf
, trap_mf
, gauss_mf
, gbell_mf
, gauss2mf
, sigmoid_mf
, dsigmoid_mf
, psigmoid_mf
, z_mf
, pi_mf
, s_mf
): A numeric vector of membership values in 0, 1, same length as x
.
For plot_mf
: A ggplot2 object, plotting the membership function.
# Define input values
x = 0:10
# Triangular membership
tri_mf(x, params = c(3, 6, 8))
# Trapezoidal membership
trap_mf(x, params = c(1, 5, 7, 8))
# Gaussian membership
gauss_mf(x, params = c(2, 5))
# Generalized bell membership
gbell_mf(x, params = c(2, 4, 6))
# Two-parameter Gaussian membership
gauss2mf(x, params = c(1, 3, 3, 4))
# Sigmoid membership
sigmoid_mf(x, params = c(2, 4))
# Difference of sigmoids membership
dsigmoid_y = dsigmoid_mf(x, params = c(5, 2, 5, 7))
# Product of sigmoids membership
psigmoid_mf(x, params = c(2, 3, -5, 8))
# Z-shaped membership
z_mf(x, params = c(3, 7))
# PI-shaped membership
pi_mf(x, params = c(1, 4, 5, 10))
# S-shaped membership
s_mf(x, params = c(1, 8))
## Not run:
# Visualize membership functions
plot_mf(\(x) tri_mf(x, c(3, 6, 8)), main = "Triangular MF")
plot_mf(\(x) trap_mf(x, c(1, 5, 7, 8)), main = "Trapezoidal MF")
plot_mf(\(x) gauss_mf(x, c(2, 5)), main = "Gaussian MF")
plot_mf(\(x) gbell_mf(x, c(2, 4, 6)), main = "Generalized Bell MF")
plot_mf(\(x) gauss2mf(x, c(1, 3, 3, 4)), main = "Two-Parameter Gaussian MF")
plot_mf(\(x) sigmoid_mf(x, c(2, 4)), main = "Sigmoid MF")
plot_mf(\(x) dsigmoid_mf(x, c(5, 2, 5, 7)), main = "Difference of Sigmoids MF")
plot_mf(\(x) psigmoid_mf(x, c(2, 3, -5, 8)), main = "Product of Sigmoids MF")
plot_mf(\(x) z_mf(x, c(3, 7)), main = "Z-Shaped MF")
plot_mf(\(x) pi_mf(x, c(1, 4, 5, 10)), main = "PI-Shaped MF")
plot_mf(\(x) s_mf(x, c(1, 8)), main = "S-Shaped MF")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.