Hi, I think I have a problem using the TRandom3(0) generator. I’m trying to create a gaussian distributiony using a monte carlo method despite the fact that gaussians distributions are already provided. This is my code:
ran = new TRandom3(0);
TH1* h1 = new TH1F("h1","gaussian, weighted", 100, -3., 3.);
double x;
for(int i=1; i<=10000; i++){
x=ran->Rndm()*6-3;
double weight=1/sqrt(2*3.14159)*exp(-1/2*pow(x,2));
h1->Fill(x, weight);
}
h1->Draw();
when I go back at the terminal in the linux and type .x and the name of the file, this message appears: error: use of undeclared identifier 'ran’
ran = new TRandom3(0);
^
and error: use of undeclared identifier 'ran’
x=ran->Rndm()*6-3;
^
what’s going wrong with the declaration of the ran variable? I’m confused…
Thanks in advance