我想绘制这个2参数函数的级别集:
def xi_gaussian_x(x,y):
sigma = 0.8
mu = 1.2
return (1.0/(sigma*np.sqrt(2*np.pi)))*(np.exp(-(x-mu)**2/(2*sigma**2)))
其中x和y介于-pi和pi之间。我的代码如下:
plt.ion()
xInterval = np.linspace(-np.pi,np.pi,num=1000)
yInterval = np.linspace(-np.pi,np.pi,num=1000)
levels_xi_gaussian_x=np.zeros((len(xInterval),len(yInterval)))
for i in range(len(xInterval)):
for j in range(len(yInterval)):
levels_xi_gaussian_x[i,j]=xi_gaussian_x(xInterval[i],yInterval[j])
plt.figure()
c = plt.contour(xInterval,yInterval,levels_xi_gaussian_x.T,50)