Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import scipy.stats as sts
- np.random.seed(123)
- y = np.linspace(50,200,150) + np.random.normal(loc=0,scale=15, size=150)
- x = np.diff(np.log(y))
- mu, sigma = sts.norm.fit(x)
- xmin, xmax = x.min(), x.max()
- x_l = np.linspace(xmin, xmax, len(x))
- dens = sts.norm.pdf(x_l, loc=mu, scale=sigma)
- plt.plot(x_l, dens)
- dens_kde = sts.gaussian_kde(x)
- dens_pdf = dens_kde.evaluate(x_l)
- plt.plot(x_l, dens_pdf)
- In [152]: from scipy.integrate import simps
- In [153]: simps(dens_pdf, x=x_l)
- Out[153]: 0.9932706185208222
Add Comment
Please, Sign In to add comment