exponentially_weighted_mean
exponentially_weighted_mean(x, alpha, skipna=False)
| Name | Type | Description | Default |
|---|---|---|---|
x | ndarray | Input array. | required |
alpha | float | Weight parameter. | required |
skipna | bool | If True, exclude NaN values from calculations using forward-fill behavior. When False (default), any NaN value causes the result to be NaN, maintaining backwards compatibility. When True, the last valid value is forward-filled through NaN values (matching pandas default behavior). | False |
| Type | Description |
|---|---|
ndarray | np.ndarray: Array with the exponentially weighted mean. |
>>> import numpy as np
>>> x = np.array([1.0, 2.0, np.nan, 4.0, 5.0])
>>> # Default behavior: NaN propagates
>>> exponentially_weighted_mean(x, alpha=0.5)
array([1., 1.5, nan, nan, nan])
>>> # With skipna=True: forward-fill through NaN
>>> exponentially_weighted_mean(x, alpha=0.5, skipna=True)
array([1., 1.5, 1.5, 2.75, 3.875])

