{ delete gRandom; gRandom = new TRandom(123456) ; // Setting the seed TH1F *gauss = new TH1F("gauss", "Gauss Distribution", 200, 0, 20); for(int i=0; i<100000; ++i) { double a=gRandom->Gaus(10, 2); gauss->Fill(a); } for(int i=0; i<100000; ++i) { double a=gRandom->Uniform(0,20); gauss->Fill(a); } TF1 *f1 = new TF1("f1", "gaus(0)+pol0(3)",0,20); // Orismos tis synartisis f1 gStyle->SetOptFit(111); // Ektypwsi toy apotelesmatos tis prosarmoghs c1=new TCanvas("c1", "Gauss", 700, 400); c1->cd(); f1->SetParameter(0,1000); // amplitude f1->SetParameter(1,10); // mean f1->SetParameter(2,1); // sigma f1->SetParameter(3,1000); // const f1->SetParName(0,"amplitude"); f1->SetParName(1,"mean"); f1->SetParName(2,"sigma"); f1->SetParName(3,"const"); gauss->Fit(f1,"","",4,16); // Prosarmogh istogrammatos stin fl apo to 4 ews to 16 }