Advertisement
Guest User

Normal vs heavy tail

a guest
Jul 25th, 2021
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import scipy.stats
  4.  
  5. plt.close('all')
  6.  
  7. mu = 1461     # taken from Bilalic et al.: "Why are (the best) women so good at chess? Participation rates and gender differences in intellectual domains", fig. 1
  8. sigma = 342
  9.  
  10. nu = 10        # degrees of freedom for t-distribution
  11.  
  12. G = scipy.stats.norm(mu, sigma)     # normal distribution
  13. T = scipy.stats.t(nu, mu, sigma)     # t-distribution
  14.  
  15. x = np.linspace(0,3000,1000)
  16.  
  17. plt.figure()
  18. plt.plot(x,G.pdf(x))
  19. plt.plot(x,T.pdf(x))
  20. plt.xlabel('ELO rating')
  21. plt.ylabel('likelihood')
  22. plt.legend(['Gaussian distribution', 't-distribution '+str(nu)+' dof']); plt.grid()
  23.  
  24. # survival function of a 3.5 sigma event
  25. p_eg = G.sf(mu+3.5*sigma)     # probability of event when gaussian
  26. p_eng = T.sf(mu+3.5*sigma)    # probability of event when not gaussian
  27.  
  28. p_g = np.array([0.5,0.7,0.8,0.9,0.95,0.98,1])    # prior probabilites for Gaussianity
  29.  
  30. result = (p_g*p_eg) / (p_g*p_eg+(1-p_g)*p_eng)
  31.  
  32. plt.figure()
  33. plt.plot(p_g,result,'*-')
  34. plt.plot([0.5,1],[0.5,0.5],'r--')
  35. plt.xlabel('prior probability that data is Gaussian')
  36. plt.ylabel('P(Gaussian | 3.5 sigma event)')
  37. plt.title('Probability that data is Gaussian conditional on observing a 3.5 sigma event\n(eqivalent to an ELO-rating of 2685))'); plt.grid()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement