# Statistics | P | 1.7 | S.Chekanov | Calculations of normalised factorial moments of several distributions # Definide as F_q=^q # authors: S.Chekanov from jhplot import * from cern.jet.random.engine import * from cern.jet.random import * from jhplot.shapes import Line from java.awt import Color from jhpro.stat import * c1 = HPlot("Canvas",600,400) c1.visible(1) c1.setNameX("NFM order") c1.setNameY("Values") c1.setRange(0,5,0,2) # show a line in the NDC system line = Line(0.0,1, 5., 1.) line.setPosCoord("USER") line.setColor(Color.gray) line.setTransparency(0.5) c1.add(line) # build a random engine engine=MersenneTwister() poisson=Poisson(10,engine) m=MomentsFacNorm(4) # calculates moments up to 4th order # use a Poissonian random numbers for i in range(100): m.process( poisson.nextInt()) p1=m.getResults() p1.setTitle("NFM for Poissson") p1.setSymbol(4) p1.setSymbolSize(10) c1.draw(p1) print(p1.toString()) ## Binomial distribution binomial=Binomial(10, 0.2, engine) m=MomentsFacNorm(4) # calculates moments up to 4th order for i in range(200): m.process( binomial.nextInt()) p2=m.getResults() p2.setTitle("NFM for Binomial") p2.setSymbol(5) p2.setSymbolSize(10) c1.draw(p2) print(p2.toString()) ## NegativeBinomial distribution (NBD) nbinom=NegativeBinomial(10, 0.4, engine) m=MomentsFacNorm(4) for i in range(300): m.process( nbinom.nextInt()) p3=m.getResults() p3.setTitle("NFM for NBD") p3.setSymbol(6) p3.setSymbolSize(10) c1.draw(p3) print(p3.toString())