import numpy as np, matplotlib.pyplot as plt
from sklearn.datasets import make_moons
X, _ = make_moons(n_samples=1500, noise=0.06, random_state=0)
X = (X - X.mean(0)) / X.std(0)
betas = np.linspace(1e-4, 0.02, 1000); abar = np.cumprod(1 - betas)
rng = np.random.default_rng(0)
steps = [0, 100, 400, 999]
fig, ax = plt.subplots(1, 4, figsize=(6.6, 1.9))
for a_, t in zip(ax, steps):
xt = np.sqrt(abar[t]) * X + np.sqrt(1 - abar[t]) * rng.normal(size=X.shape)
a_.scatter(xt[:, 0], xt[:, 1], s=3, alpha=0.4)
a_.set_title(f"t = {t}", fontsize=8); a_.set_xticks([]); a_.set_yticks([])
a_.set_xlim(-3, 3); a_.set_ylim(-3, 3)
plt.tight_layout(); plt.show()