EMA

Created
Created
2025 Jan 27 21:41
Creator
Creator
Seonglae ChoSeonglae Cho
Editor
Edited
Edited
2026 Mar 23 11:58
Refs
Refs

Exponential smoothing or exponential moving average

notion image
import numpy as np import matplotlib.pyplot as plt # Generate noisy data np.random.seed(42) # For reproducibility time = np.arange(1, 101) values = 50 + np.cumsum(np.random.randn(100) * 10) # Large noise # Calculate EMA alpha = 0.3 # Smoothing factor ema_direct = [] alpha = 0.3 for i, value in enumerate(values): if i == 0: ema_direct.append(value) # Initialize EMA with the first value else: ema_direct.append(alpha * value + (1 - alpha) * ema_direct[-1]) # Plot the noisy data and EMA plt.figure(figsize=(10, 6)) plt.plot(time, values, label='Noisy Data', alpha=0.7) plt.plot(time, ema_direct, label='Exponential Moving Average (EMA)', linewidth=2, color='orange') plt.title('Noisy Data with Exponential Moving Average') plt.xlabel('Time') plt.ylabel('Value') plt.legend() plt.grid(True) plt.show()
  • EMA applies more weight to the recent data exponentially for interpolation
 
 
Exponential smoothing
Exponential smoothing or exponential moving average (EMA) is a rule of thumb technique for smoothing time series data using the exponential window function. Whereas in the simple moving average the past observations are weighted equally, exponential functions are used to assign exponentially decreasing weights over time. It is an easily learned and easily applied procedure for making some determination based on prior assumptions by the user, such as seasonality. Exponential smoothing is often used for analysis of time-series data.
 
 

Recommendations