1. Plot the function:f(x) =sin
2(x-2)*e
x
^
2 over the interval [0; 2]. Add proper axis labels, a title, etc.
python代码如下:
import numpy as np
import matplotlib.pyplot as plt
f,ax = plt.subplots(1,1,figsize = (5,4))
x = np.linspace(0, 2, 100)
y = np.power(np.sin(x-2), 2)*np.power(np.e, -np.power(x, 2))
ax.plot(x, y)
ax.set_xlim((0, 2))
ax.set_ylim((0, 1))
ax.set_xlabel("my x label")
ax.set_ylabel("my y label")
ax.set_title('function image')
plt.show()
结果如图:
2. 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 variables.