/* randomDistributions.cxx
Using a Random class (see random.h), plots the results of
popular random number generators.
Aug 2008
*/
#include <cstdlib>
#include "random.h"
void randomDistributions(){
int n = 20000;
Random r;
// The canvas
TCanvas *c1 = new TCanvas("c1","Popular random distributions",10,10,600,500);
// The histograms
TH1D *h1 = new TH1D("h1","Flat distribution ",50, 0.0, 1.0);
TH1D *h2 = new TH1D("h2","Gauss distribution ",50,-5.0, 5.0);
TH1D *h3 = new TH1D("h3","Exponential distribution ",50, 0.0, 10.);
TH1D *h4 = new TH1D("h4","Breit-Wigner distribution",50,-5.0, 5.0);
TH1D *h5 = new TH1D("h5","Integer distribution ",8 ,-0.5, 7.5);
h1->SetMinimum(0);
h2->SetMinimum(0);
h3->SetMinimum(0);
h4->SetMinimum(0);
h5->SetMinimum(0);
// Fill the histograms
for(int i=0; i<n; i++)
{
h1->Fill( r.Flat() );
h2->Fill( r.Gauss() );
h3->Fill( r.Exponential(2.0) );
h4->Fill( r.BreitWigner() );
h5->Fill( r.Integer(1,6) );
}
// Draw the histogram now
h1->Draw();
//h2->Draw();
//h3->Draw();
//h4->Draw();
//h5->Draw();
}