import numpy as np import matplotlib.pyplot as plt # ── Parameters ────────────────────────────────────────────────────────────── seed = 5909 n_points = 38 slope = -0.918191 intercept = -1.427642 noise_std = 0.533250 # ── Data ──────────────────────────────────────────────────────────────────── rng = np.random.default_rng(seed) x = np.sort(rng.uniform(-3.0, 3.0, n_points)) y = slope * x + intercept + rng.normal(0.0, noise_std, n_points) x_line = np.array([-3.0, 3.0]) y_line = slope * x_line + intercept # ── Plot ───────────────────────────────────────────────────────────────────── fig, ax = plt.subplots(figsize=(6, 5)) ax.scatter(x, y, alpha=0.6, s=30, color="steelblue", zorder=2) ax.plot(x_line, y_line, color="crimson", linewidth=2, zorder=3, label=f"y = {slope:.3f}x + {intercept:.3f}") ax.set_xlabel("x") ax.set_ylabel("y") ax.set_title(f"Linear Scatter (n={n_points})") ax.legend(fontsize=9) ax.grid(True, alpha=0.3) fig.tight_layout() plt.show()