Skip to content

Instantly share code, notes, and snippets.

@MinaGabriel
Created July 23, 2019 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MinaGabriel/e3335d75edb03b696015a7d033fddebd to your computer and use it in GitHub Desktop.
Save MinaGabriel/e3335d75edb03b696015a7d033fddebd to your computer and use it in GitHub Desktop.
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np
from scipy.stats import norm
fig = plt.figure()
ax = fig.gca(projection='3d')
# Make data.
X = np.arange(0.01, 10, 0.1)
Y = np.arange(0.01, 10, 0.1)
X, Y = np.meshgrid(X, Y)
Z = norm(X, Y).pdf(5) * norm(X, Y).pdf(6)
mina = np.array(Z).reshape(1,-1)
print(max(mina[0]))
# Plot the surface.
surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm, alpha=0.4,
linewidth=0.2, antialiased=False)
# Customize the z axis.
ax.set_zlim(0, 0.2)
ax.set_xlim(-1, 10)
ax.set_ylim(-1, 10)
ax.zaxis.set_major_locator(LinearLocator(5))
ax.set_zticklabels([])
ax.view_init(30, 25)
ax.set_xlabel('$\mu$')
ax.set_ylabel('$\sigma$')
ax.set_zlabel('$p(5 | \mu, \sigma)$ X $p(6 | \mu, \sigma) $')
# Add a color bar which maps values to colors.
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment