1. Making wallpaper with fromfunction
Adapted from Circle Squared
Create a \(400 \times 400\) array using the function
lambda i, j: 0.27**2*(i**2 + j**2) % 1.5. Use imshow from
matplotlib.pyplot with interpolation='nearest' and the
YlOrBr colormap to display the resulting array as an image.
In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
In [ ]:
2. Find t least squares solution for \(\beta_0, \beta_1, \beta_2\) using the normal equations \(\hat{\beta} = (X^TX)^{-1}x^Ty\).
\begin{align}
10 &= \beta_0 + 3 \beta_1 + 7 \beta_2 \\
11 &= \beta_0 + 2 \beta_1 + 8 \beta_2 \\
9 &= \beta_0 + 3 \beta_1 + 7 \beta_2 \\
10 &= \beta_0 + 1 \beta_1 + 9 \beta_2 \\
\end{align}
You can find the inverse of a matrix by using np.linalg.inv and the
transpose with X.T
In [ ]: