Newer
Older
Lecture_repo / Lectures_my / EMPP / MC_examples / CLT / clt.py
@mchrzasz mchrzasz on 6 Sep 2015 662 bytes CLT fix
  1. from ROOT import *
  2. import sys
  3.  
  4. def main(argv=sys.argv):
  5.  
  6.  
  7. pi=3.14159265359
  8. c=TCanvas("c1", "c1", 800,600)
  9. NTOYS=1000000
  10. rand=TRandom(123)
  11.  
  12. hists=[]
  13.  
  14. for i in range(1,13, 2):
  15. hist=TH1D("hist", "hist", 400, 0, 10)
  16. for j in range(0, NTOYS):
  17. tmp=0.
  18. for k in range(0,i):
  19. tmp+=rand.Rndm()
  20. hist.Fill(tmp)
  21. hists.append(hist)
  22.  
  23. for i in range(0,len(hists)):
  24. if(i==0): hists[i].DrawNormalized()
  25. else: hists[i].DrawNormalized("SAME")
  26.  
  27. c.SaveAs("clt.png")
  28. c.SaveAs("clt.pdf")
  29. if __name__ == "__main__":
  30. sys.exit(main())