void binom()
{

 gROOT->Reset();
 gROOT->SetStyle("Plain");

 TRandom *r3 = new TRandom3();

 const Int_t nPoints = 10000;

 // P(n;N,p) n is binomially distributed between 0 and N inclusive
 // with mean p*N, p is between 0 and 1. (da documentacao do Root)

 // observe que as entradas tem um peso para que o hist seja normalizado 

 // display distrib
 TCanvas *bin = new TCanvas("bin"," binomial ", 600,600);
 TH1F *h  = new TH1F("hexp"," ", 20,0.0,20.0);
 for (Int_t i=0;i<nPoints;i++){
   Double_t x = r3->Binomial(20,0.5);
   h->Fill(x,1.0/nPoints);
  }
 h->GetXaxis()->SetTitle("x");
 h->GetYaxis()->SetTitleOffset(1.5);
 h->GetYaxis()->SetTitle("f(n;N,p)");
 h->SetStats(kFALSE);
 h->SetMaximum(0.4);
 h->SetFillColor(2);
 h->SetBarWidth(0.4);
 h.Draw("bar");
 bin->Update();
}
