import matplotlib.pyplot as pltimport numpy as np# Parameterseta =0.8# Smoothing factorsteps =2# Step size for x-axisn_points =200# Number of points# Generate datax = np.arange(0, n_points, steps)data = np.sin(x /5) + np.random.normal(0, 0.3, len(x)) # Random data with noiseema = []# Calculate EMAfor i, point inenumerate(data):if i ==0: ema.append(point) # Initialize EMA with the first data pointelse: ema.append(eta * point + (1- eta) * ema[-1])# Plotplt.figure(figsize=(8, 3))plt.plot(x, data, label="Data", marker="o", linestyle="--", alpha=0.6)plt.plot(x, ema, label="Exponential Moving Average (EMA)", linewidth=2)plt.xlabel("Step")plt.ylabel("Value")plt.title(f"Exponential Moving Average (eta={eta}, step={steps}) ")plt.legend()plt.grid(True)plt.show()