Bell¶
- class pumas.desirability.bell.Bell(params: Dict[str, Any] | None = None)[source]¶
- compute_numeric(x: int | float) float[source]¶
Compute the bell desirability for a numeric input.
- Parameters:
x (Union[int, float]) – The numeric input value.
- Returns:
The computed desirability value.
- Return type:
float
- Raises:
InvalidParameterTypeError – If the input is not a float.
ParameterValueNotSet – If any required parameter is not set.
- compute_ufloat(x: AffineScalarFunc) AffineScalarFunc[source]¶
Compute the bell desirability for an uncertain float input.
- Parameters:
x (UFloat) – The uncertain float input value.
- Returns:
The computed desirability value with uncertainty.
- Return type:
UFloat
- Raises:
InvalidParameterTypeError – If the input is not a UFloat.
ParameterValueNotSet – If any required parameter is not set.
- name: ClassVar[str] = 'bell'¶
Bell desirability function implementation.
Mathematical Definition:
The bell function is defined as:
\[f(x) = \frac{1}{1 + |\frac{x - center}{width}|^{2 * slope}} * (1 - shift) + shift\]- Where:
x is the input value.
width is the width parameter of the bell curve, controls the horizontal spread (width > 0).
slope is the slope parameter of the bell curve, controls the steepness of the curve’s sides.
center is the center of the bell curve, indicates the x value at the highest point of the curve (peak).
invert is a boolean parameter that, if True, inverts the curve.
shift is the vertical shift applied to the entire curve, ranging from 0 (no shift) to 1 (maximum shift).
- Parameters:
params (Optional[Dict[str, Any]]) – Initial parameters for the sigmoid function. Defaults to None.
- width¶
The width parameter of the bell curve, controls the horizontal spread (width > 0).
- Type:
float
- slope¶
The slope parameter of the bell curve, controls the steepness of the curve’s sides.
- Type:
float
- center¶
The center of the bell curve, indicates the x value at the highest point of the curve (peak).
- Type:
float
- invert¶
If True, the curve is inverted, i.e., the desirability decreases as x approaches the center.
- Type:
bool
- shift¶
The vertical shift applied to the entire curve, ranging from 0 (no shift) to 1 (maximum shift).
- Type:
float
Usage Example:
>>> from pumas.desirability import desirability_catalogue
>>> desirability_class = desirability_catalogue.get("bell")
>>> params = {'center': 0.5, 'width': 1.0, 'slope': 2.0, 'invert': False, 'shift': 0.0} >>> desirability = desirability_class(params=params) >>> print(desirability.get_parameters_values()) {'center': 0.5, 'width': 1.0, 'slope': 2.0, 'invert': False, 'shift': 0.0}
>>> result = desirability.compute_numeric(x=0.5) >>> print(f"{result:.2f}") 1.00
>>> result = desirability(x=0.5) # Same as compute_numeric >>> print(f"{result:.2f}") 1.00
>>> from uncertainties import ufloat >>> result = desirability.compute_ufloat(x=ufloat(0.5, 0.1)) >>> print(result) 1.0+/-0
- class pumas.desirability.bell.bell(x: float | ~uncertainties.core.AffineScalarFunc, width: float, slope: float, center: float, invert: bool = False, shift: float = 0.0, math_module: ~types.ModuleType = <module 'math' from '/home/docs/.asdf/installs/python/3.12.10/lib/python3.12/lib-dynload/math.cpython-312-x86_64-linux-gnu.so'>)[source]¶
Parameter Analysis¶
(Source code, png, hires.png, pdf)