11.1
# -*- coding: utf-8 -*-
"""
Created on Tue May 29 19:34:16 2018
@author: 12046
"""
import numpy as np
import scipy
import matplotlib.pyplot as plt
def f(x):
return (np.sin(x-2)**2)*(np.e**(-(x**2)))
x = np.linspace(0,2,1000)
y = f(x)
plt.plot(x,y)
plt.xlabel('x')
plt.ylabel('y=f(x)')
plt.title(r'$f(x) = \mathrm{sin}^2(x-2)*{e}^{-x^2}$')
plt.savefig('a.jpg')
输出图像
11.2
# -*- coding: utf-8 -*-
"""
Created on Tue May 29 20:09:29 2018
@author: 12046
"""
import numpy as np
import scipy
import matplotlib.pyplot as plt
X=np.random.randn(20,10)*np.random.rand