Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save olegsinavski/05065a4f5fcf378312dbb1c567135049 to your computer and use it in GitHub Desktop.
Save olegsinavski/05065a4f5fcf378312dbb1c567135049 to your computer and use it in GitHub Desktop.
Fit Student-t and normal distribution in python
import scipy
import scipy.stats
plt.hist(noise, bins=100, normed=1)
x = np.linspace(-0.2, 0.2, len(noise))
dist_names = ['norm', 't']
for dist_name in dist_names:
dist = getattr(scipy.stats, dist_name)
param = dist.fit(noise)
pdf_fitted = dist.pdf(x, *param[:-2], loc=param[-2], scale=param[-1])
plt.plot(x, pdf_fitted, label=dist_name)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment