代码:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 2, 100)
y = (np.sin(x - 2) ** 2) * np.exp(-(x ** 2))
plt.plot(x, y)
plt.xlabel('my x label')
plt.ylabel('my y label')
plt.title('$f(x) = sin^2(x-2){e^{-x^2}}$')
plt.savefig('function.pdf')
结果:
代码:
import numpy as np
import matplotlib.pyplot as plt
X = np.random.random_sample((20, 10)) * 10
b = np.random.random(10) * 3 - 1.5
z = np.random.normal((20,))
y = np.dot