Exponential Decay¶
- class pumas.desirability.exponential_decay.ExponentialDecay(params: Dict[str, Any] | None = None)[source]¶
- compute_numeric(x: int | float) float[source]¶
Compute the exponential decay 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 exponential decay 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] = 'exponential_decay'¶
Exponential decay desirability function implementation.
Mathematical Definition:
The exponential decay function is defined as:
\[\begin{split}f(x) = \begin{cases} 1.0 & \text{if } x < 0 \\ e^{-k \cdot x} & \text{if } x \geq 0 \end{cases}\end{split}\]With optional shift transformation:
\[f_{final}(x) = f(x) \cdot (1 - shift) + shift\]- Where:
x is the input value.
k is the decay rate parameter (k > 0). Higher values result in faster decay.
shift is the vertical shift applied to the entire curve, ranging from 0 (no shift) to 1 (maximum shift).
For x < 0, the function is “rectified” or “clamped” to 1.0, meaning full desirability.
- Parameters:
params (Optional[Dict[str, Any]]) – Initial parameters for the exponential decay function. Defaults to None.
- k¶
The decay rate parameter (k > 0). Higher values result in faster decay.
- Type:
float
- 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("exponential_decay")
>>> params = {'k': 1.0, 'shift': 0.0} >>> desirability = desirability_class(params=params) >>> print(desirability.get_parameters_values()) {'k': 1.0, 'shift': 0.0}
>>> result = desirability.compute_numeric(x=0.0) >>> print(f"{result:.2f}") 1.00
>>> result = desirability.compute_numeric(x=1.0) >>> print(f"{result:.2f}") 0.37
>>> result = desirability(x=-1.0) # Clamped to 1.0 >>> print(f"{result:.2f}") 1.00
>>> from uncertainties import ufloat >>> result = desirability.compute_ufloat(x=ufloat(1.0, 0.1)) >>> print(result) 0.37+/-0.04
- class pumas.desirability.exponential_decay.exponential_decay(x: float | ~uncertainties.core.AffineScalarFunc, k: float, 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]¶
Exponential decay function: exp(-k*x) for x >= 0, clamped to 1.0 for x < 0.
- Parameters:
x (Union[float, UFloat]) – The input value.
k (float) – The decay rate parameter.
shift (float, optional) – The vertical shift. Defaults to 0.0.
math_module (ModuleType, optional) – The math module to use. It uses math for numerical computations and umath for uncertain computations. Defaults to math.
- Returns:
The result of the exponential decay function.
- Return type:
Union[float, UFloat]
Parameter Analysis¶
(Source code, png, hires.png, pdf)