base = {
"min_length": 200,
"max_length": 200,
"freq": "D",
"mu": 100.0,
"sigma": 5.0,
"initial_value": 60.0,
"seed": 42,
}
fig, ax = plt.subplots(figsize=(12, 4))
for theta in (0.05, 0.3, 1.5):
df = OrnsteinUhlenbeckGenerator(engine="polars", theta=theta, **base).generate(
n_series=1
)
ax.plot(df["ds"].to_list(), df["y"].to_list(), label=f"theta={theta}", alpha=0.85)
ax.axhline(base["mu"], color="black", linestyle="--", linewidth=1, label="mu")
ax.set(
xlabel="Timestamp",
ylabel="Value",
title="Reversion speed: large theta snaps back to mu, small theta wanders",
)
ax.legend(fontsize=8)
plt.tight_layout()
plt.show()