Guest User

Untitled

a guest
Feb 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import numpy as np
  2. import scipy.stats as sts
  3.  
  4. np.random.seed(123)
  5. y = np.linspace(50,200,150) + np.random.normal(loc=0,scale=15, size=150)
  6. x = np.diff(np.log(y))
  7. mu, sigma = sts.norm.fit(x)
  8. xmin, xmax = x.min(), x.max()
  9. x_l = np.linspace(xmin, xmax, len(x))
  10. dens = sts.norm.pdf(x_l, loc=mu, scale=sigma)
  11. plt.plot(x_l, dens)
  12.  
  13. dens_kde = sts.gaussian_kde(x)
  14. dens_pdf = dens_kde.evaluate(x_l)
  15. plt.plot(x_l, dens_pdf)
  16.  
  17. In [152]: from scipy.integrate import simps
  18.  
  19. In [153]: simps(dens_pdf, x=x_l)
  20. Out[153]: 0.9932706185208222
Add Comment
Please, Sign In to add comment