Advertisement
bartekltg

estymator

Jun 26th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. import numpy
  2. from matplotlib import pyplot
  3. from scipy import  stats
  4.  
  5.  
  6. def test (n,k,ns):
  7.     r=stats.expon.rvs(loc =0, size = (ns,n),scale = 10)
  8.     rr=numpy.sort(r, axis = 1)
  9.     est_scale = (numpy.sum( rr[:,0:k],axis=1 )+(n-k)*rr[:,k-1])/k
  10.     pyplot.figure()
  11.     pyplot.hist(est_scale,bins = 30)
  12.     pyplot.title( str(k)+" z "+str(n) )
  13.     pyplot.show()
  14.     print(n,k,numpy.mean(est_scale))
  15.  
  16.  
  17. test(10,10,10000)
  18. test(10,5,10000)
  19. test(10,2,10000)
  20.  
  21. test(100,50,10000)
  22. test(100,10,10000)
  23. test(100,5,10000)
  24. test(100,1,10000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement