PIMF
Pi-function fuzzy membership generator. Equivalently a product of the S-function (smf) and Z-function (zmf).
The function begins to climb from zero at the left ‘foot’ (a), levels off at 1 at the left ‘ceiling’ (b), begins falling from 1 at the right ‘ceiling’ (c), and reattains zero at the right ‘foot’ (d).
Excel Usage
=PIMF(x, a, b, c, d)
x(list[list], required): Array of independent universe variables.a(float, required): Left foot, where the function begins to climb from zero.b(float, required): Left ceiling, where the function levels off at 1.c(float, required): Right ceiling, where the function begins falling from 1.d(float, required): Right foot, where the function reattains zero.
Returns (list[list]): Array of membership values corresponding to the input universe.
Example 1: Pi-function membership with a flat top
Inputs:
| x | a | b | c | d | |||||
|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 2 | 3 | 4 | 5 | 1 | 2 | 3 | 4 |
Excel formula:
=PIMF({0,1,2,3,4,5}, 1, 2, 3, 4)
Expected output:
| Result |
|---|
| 0 |
| 0 |
| 1 |
| 1 |
| 0 |
| 0 |
Example 2: Pi-function membership inside the plateau
Inputs:
| x | a | b | c | d |
|---|---|---|---|---|
| 2.5 | 1 | 2 | 3 | 4 |
Excel formula:
=PIMF(2.5, 1, 2, 3, 4)
Expected output:
1
Example 3: Pi-function membership with wider transition regions
Inputs:
| x | a | b | c | d | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 1 | 2.5 | 3.5 | 5 |
Excel formula:
=PIMF({0,1,2,3,4,5,6}, 1, 2.5, 3.5, 5)
Expected output:
| Result |
|---|
| 0 |
| 0 |
| 0.777778 |
| 1 |
| 0.777778 |
| 0 |
| 0 |
Example 4: Pi-function membership over an asymmetric support
Inputs:
| x | a | b | c | d | |||||
|---|---|---|---|---|---|---|---|---|---|
| -2 | -1 | 0 | 1 | 2 | 3 | -1 | 0 | 1.5 | 3 |
Excel formula:
=PIMF({-2,-1,0,1,2,3}, -1, 0, 1.5, 3)
Expected output:
| Result |
|---|
| 0 |
| 0 |
| 1 |
| 1 |
| 0.777778 |
| 0 |
Python Code
Show Code
import numpy as np
from skfuzzy import pimf as fuzz_pimf
def pimf(x, a, b, c, d):
"""
Generate a Pi-function fuzzy membership generator.
See: https://pythonhosted.org/scikit-fuzzy/api/skfuzzy.html#skfuzzy.pimf
This example function is provided as-is without any representation of accuracy.
Args:
x (list[list]): Array of independent universe variables.
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:
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 not (a <= b <= c <= d):
return "Error: Parameters must satisfy a <= b <= c <= d"
result = fuzz_pimf(x_arr, a, b, c, d)
return [[float(val)] for val in result]
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Array of independent universe variables.
Left foot, where the function begins to climb from zero.
Left ceiling, where the function levels off at 1.
Right ceiling, where the function begins falling from 1.
Right foot, where the function reattains zero.