In [63]:
from scipy.stats import multivariate_normal

In [64]:
# covariance matrix
cov = [[1, 0],[0,1]]
# mean vector
mu = np.array([0,0])

In [65]:
# define the grid
x = y = linspace(-4, 4, 200)
X, Y = np.meshgrid(x,y)
pos = np.dstack((X,Y))

In [66]:
z = multivariate_normal(mean = mu,cov= cov)
z.pdf([0,0])


Out[66]:
0.15915494309189535

In [67]:
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, z.pdf(pos), shade=1, alpha=1, cmap='BuGn')


Out[67]:
<mpl_toolkits.mplot3d.art3d.Poly3DCollection at 0x57778d0>

In [68]:
# covariance matrix
cov = [[.7, 0.0],[0.0,.7]]
# mean vector
mu = np.array([0,0])

In [69]:
z = multivariate_normal(mean = mu,cov= cov)
z.pdf([0,0])


Out[69]:
0.2273642044169934

In [70]:
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, z.pdf(pos), shade=1, alpha=1, cmap='BuGn')


Out[70]:
<mpl_toolkits.mplot3d.art3d.Poly3DCollection at 0x576a510>

In [ ]: