A lightweight, streaming-friendly Exponentially Weighted Moving Average (EWMA) library for Python.
Designed for real-time metrics, analytics, and streaming data.
- Streaming / online updates in O(1) time and memory
- Configurable smoothing factor (
alpha) - Optional initial value
- Reset and reuse EWMA instances
- Fully tested with
pytest - Type hints for modern Python (>=3.9)
from ewma import EWMA
# Create an EWMA instance
ewma = EWMA(alpha=0.2)
# Stream data
for x in [10, 20, 30]:
print(ewma.update(x))
# Access current value
print("Current EWMA:", ewma.value())
# Reset
ewma.reset(initial_value=5.0)pip install git+https://github.com/udaypatel1/ewma.git