Example 2.14#
Let us look at the simulation of a linear regression model.
import numpy as np
import matplotlib.pyplot as plt
rng = np.random.default_rng(12)
n = 10000
x = rng.uniform(-10, 10, n)
a = 0.5
b = 0.5
sigma_0 = 0.5 # this is the standard deviation, not the variance!
y = a * x + b + np.random.normal(0, sigma_0, n)
plt.scatter(x, y, color='k', alpha=1, s=0.05)
plt.show()
# plt.pause(10)