GBELLMF

Generates a Generalized Bell fuzzy membership function. The function is defined by three parameters: width (a), slope (b), and center (c).

The equation is defined as: y(x) = 1 / (1 + abs([x - c] / a) ** [2 * b])

Excel Usage

=GBELLMF(x, a, b, c)
  • x (list[list], required): Array of independent universe variables.
  • a (float, required): Bell function parameter controlling width.
  • b (float, required): Bell function parameter controlling slope.
  • c (float, required): Bell function parameter defining the center.

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

Example 1: Generalized bell membership around the center

Inputs:

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

Excel formula:

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

Expected output:

Result
0.024961
0.164948
0.941176
0.941176
0.164948
0.024961
Example 2: Generalized bell membership at its center

Inputs:

x a b c
2.5 1 2 2.5

Excel formula:

=GBELLMF(2.5, 1, 2, 2.5)

Expected output:

1

Example 3: Generalized bell with a broader width

Inputs:

x a b c
-2 -1 0 1 2 2 2 0

Excel formula:

=GBELLMF({-2,-1,0,1,2}, 2, 2, 0)

Expected output:

Result
0.5
0.941176
1
0.941176
0.5
Example 4: Generalized bell centered on a negative value

Inputs:

x a b c
-4 -3 -2 -1 0 1.5 3 -2

Excel formula:

=GBELLMF({-4,-3,-2,-1,0}, 1.5, 3, -2)

Expected output:

Result
0.151088
0.919294
1
0.919294
0.151088

Python Code

Show Code
import numpy as np
from skfuzzy import gbellmf as fuzz_gbellmf

def gbellmf(x, a, b, c):
    """
    Generate a Generalized Bell fuzzy membership function.

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

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

    Args:
        x (list[list]): Array of independent universe variables.
        a (float): Bell function parameter controlling width.
        b (float): Bell function parameter controlling slope.
        c (float): Bell function parameter defining the center.

    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"

        if a == 0:
            return "Error: a must be nonzero"

        result = fuzz_gbellmf(x_arr, a, 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.
Bell function parameter controlling width.
Bell function parameter controlling slope.
Bell function parameter defining the center.