Skip to content

Instantly share code, notes, and snippets.

@gunnarvoet
Last active April 8, 2018 20:02
Show Gist options
  • Save gunnarvoet/69f2a446bc896fa476f3 to your computer and use it in GitHub Desktop.
Save gunnarvoet/69f2a446bc896fa476f3 to your computer and use it in GitHub Desktop.
Plot a histogram and fit a normal pdf in python
plt.hist(data),normed=True,stacked=True,facecolor='0.5');
from scipy.stats import norm
mu, std = norm.fit(data)
std = float(std)
xmin, xmax = plt.xlim()
x = np.linspace(xmin, xmax, 100)
p = norm.pdf(x, mu, std)
plt.plot(x, p, 'k', linewidth=2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment