``` 1 # Random distributions. Verious random distributions according to predifined PDF 2 # S.Chekanov 3 4 """

Random distributions

Random distributions are discussed in this Wikipedia article """ 9 10 from java.awt import Color 11 from jhplot import * 12 from cern.jet.random.engine import * 13 from cern.jet.random import * 14 15 16 # build a singleton 17 c1=HPlot("Canvas",650,500,3,2) 18 c1.visible() 19 c1.setAutoRange() 20 c1.setGTitle("Random Distributions") 21 22 engine = MersenneTwister() 23 Events=5000 24 25 c1.cd(1,1) 26 r=Gamma(1,0.5,engine) 27 h1=H1D("Gamma",25,0,10) 28 h1.setFill(1) 29 h1.setFillColor(Color.red) 30 h1.fill(1000,r) 31 c1.draw(h1) 32 33 c1.cd(2,1) 34 c1.setAutoRange() 35 r=Binomial(10,0.5,engine) 36 h1=H1D("Binominal",20,0,10) 37 h1.setFill(1) 38 h1.setFillColor(Color.blue) 39 h1.fill(1000,r) 40 c1.draw(h1) 41 42 c1.cd(3,1) 43 c1.setAutoRange() 44 r=Poisson(5,engine) 45 h1=H1D("Poisson",20,0,10) 46 h1.setFill(1) 47 h1.setFillColor(Color.green) 48 h1.fill(1000,r) 49 c1.draw(h1) 50 51 c1.cd(1,2) 52 c1.setAutoRange() 53 r=StudentT(5,engine) 54 h1=H1D("Student",20,0,5) 55 h1.setFill(1) 56 h1.setFillColor(Color.green) 57 h1.fill(1000,r) 58 c1.draw(h1) 59 60 c1.cd(2,2) 61 c1.setAutoRange() 62 r=NegativeBinomial(10,0.5,engine) 63 h1=H1D("NBD",30,0,30) 64 h1.setFill(1) 65 h1.setFillColor(Color.red) 66 h1.fill(1000,r) 67 c1.draw(h1) 68 69 c1.cd(3,2) 70 c1.setAutoRange() 71 r=Logarithmic(0.5,engine) 72 h1=H1D("Logarithmic",20,0,10) 73 h1.setFill(1) 74 h1.setFillColor(Color.blue) 75 h1.fill(1000,r) 76 c1.draw(h1) ### © jHepWork. S.Chekanov ### ```