Created
July 11, 2017 23:41
-
-
Save olegsinavski/05065a4f5fcf378312dbb1c567135049 to your computer and use it in GitHub Desktop.
Fit Student-t and normal distribution in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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