Exercise 11.1: Plotting a function
Plot the function
over the interval [0,2]. Add proper axis labels, a title, etc.
import numpy as np
import matplotlib.pyplot as plt
xarr = np.linspace(0, 2, 1000)
yarr = [(np.sin(x-2)**2)*np.exp(-x**2) for x in xarr]
plt.plot(xarr, yarr)
plt.title('A function')
plt.xlabel('x')
plt.ylabel('y')
plt.axis((0, 2, 0, 1))
plt.show()
Exercise 11.2: Data
Create a data matrix X with 20 observations of 10 variables. Generate a vector b with parameters Then generate the response vector y = Xb+z where z is a vector with standard normally distributed vari