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)
../_images/a449b22d40f89772e67aa2e3980adca44213ad0a2bf573a16badcfb09a464d84.png