SIGMF

Generates a basic sigmoid membership function. The shape of the sigmoid is defined by its center point and width.

The equation for the sigmoid function is: y = 1 / (1. + exp[- c * (x - b)]). With c > 0, the left side approaches 0 and right side approaches 1. With c < 0, the opposite is true.

Excel Usage

=SIGMF(x, b, c)
  • x (list[list], required): Array of independent universe variables.
  • b (float, required): Offset or bias. This is the center value of the sigmoid, where it equals 0.5.
  • c (float, required): Controls width of the sigmoidal region (magnitude) and which side is open (sign).

Returns (list[list]): Array of membership values corresponding to the input universe.

Example 1: Increasing sigmoid membership profile

Inputs:

x b c
0 1 2 3 4 5 2.5 1

Excel formula:

=SIGMF({0,1,2,3,4,5}, 2.5, 1)

Expected output:

Result
0.0758582
0.182426
0.377541
0.622459
0.817574
0.924142
Example 2: Decreasing sigmoid membership profile

Inputs:

x b c
0 1 2 3 4 5 2.5 -1

Excel formula:

=SIGMF({0,1,2,3,4,5}, 2.5, -1)

Expected output:

Result
0.924142
0.817574
0.622459
0.377541
0.182426
0.0758582
Example 3: Sigmoid membership at its midpoint

Inputs:

x b c
2.5 2.5 3

Excel formula:

=SIGMF(2.5, 2.5, 3)

Expected output:

0.5

Example 4: Sigmoid membership with a shallow slope

Inputs:

x b c
-2 -1 0 1 2 0 0.5

Excel formula:

=SIGMF({-2,-1,0,1,2}, 0, 0.5)

Expected output:

Result
0.268941
0.377541
0.5
0.622459
0.731059

Python Code

Show Code
import numpy as np
from skfuzzy import sigmf as fuzz_sigmf

def sigmf(x, b, c):
    """
    Generate a basic sigmoid membership function.

    See: https://pythonhosted.org/scikit-fuzzy/api/skfuzzy.html#skfuzzy.sigmf

    This example function is provided as-is without any representation of accuracy.

    Args:
        x (list[list]): Array of independent universe variables.
        b (float): Offset or bias. This is the center value of the sigmoid, where it equals 0.5.
        c (float): Controls width of the sigmoidal region (magnitude) and which side is open (sign).

    Returns:
        list[list]: Array of membership values corresponding to the input universe.
    """
    try:
        def to1d(arr):
            if isinstance(arr, list):
                flat = []
                for row in arr:
                    row_list = row if isinstance(row, list) else [row]
                    for val in row_list:
                        try:
                            flat.append(float(val))
                        except (TypeError, ValueError):
                            continue
                return np.array(flat)
            return np.array([float(arr)])

        x_arr = to1d(x)
        if len(x_arr) == 0:
            return "Error: Input mapping array x cannot be empty"

        result = fuzz_sigmf(x_arr, b, c)
        return [[float(val)] for val in result]
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Array of independent universe variables.
Offset or bias. This is the center value of the sigmoid, where it equals 0.5.
Controls width of the sigmoidal region (magnitude) and which side is open (sign).