Hi ROOTers, I've written a simple script that defines a TF3 with a simple Maxwell-Boltzman like velocity distribution and uses this to fill a TH3. I then use the GetRandom3 methods of TF3 and TH3 to generate three random numbers and use these numbers to get the speed distributions (filled into two TH1Fs). I expected to find the two speed distributions to be identical, but that generated by the call to TF3::GetRandom3 produces the wrong distribution, it's double peaked rather than single peaked (the script code is included below). In the application I'm developing, I'd rather use the TF3 directly rather than having to fill a histogram first. Is there some mistake in how I've defined the TFormula and TF3, or is it a problem with TF3::GetRandom3? I'm using ROOT 3.02/07 on a RH7.1 Linux PC. Thanks in advance for any advice, Ben Morgan. { gROOT->Reset(); Float_t x,y,z; Axis_t v1,v2,v3; Double_t w1,w2,w3; hmodel = new TFormula("MB","exp(-1*(pow(x,2)+pow(y,2)+pow(z,2))/1)"); maxbolt = new TF3("Maxwell-Boltzmann","MB",-10,10,-10,10,-10,10); TH3F *t1 = new TH3F("t1","gaussian",100,-5,5,100,-5,5,100,-5,5); TH1F *v = new TH1F("v1","Speed",100,0,5); TH1F *w = new TH1F("w1","Speed",100,0,5); t1->FillRandom("Maxwell-Boltzmann",1000000); for(Int_t i=0; i<1000000; i++) { t1->GetRandom3(v1,v2,v3); Float_t vel = sqrt(pow(v1,2)+pow(v2,2)+pow(v3,2)); v->Fill(vel); maxbolt->GetRandom3(w1,w2,w3); vel = sqrt(pow(w1,2)+pow(w2,2)+pow(w3,2)); w->Fill(vel+1); //Shifts w distribution to make differences obvious } v->Draw(); w->Draw("same"); } -- ------------------------------------------------------------------------------- Mr. Ben Morgan Tel: 44 (0)114 22 23553 (Work) Postgraduate Student University of Sheffield Department of Physics & Astronomy Hicks Building Hounsfield Road Sheffield S3 7RH -------------------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:14 MET