Logo ROOT   6.10/09
Reference Guide
TRandom.cxx
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Author: Rene Brun, Lorenzo Moneta 15/12/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /**
13 
14 \class TRandom
15 
16 @ingroup Random
17 
18 This is the base class for the ROOT Random number generators.
19 This class defines the ROOT Random number interface and it should not be instantiated directly but used via its derived classes
20 (e.g. TRandom1, TRandom2 or TRandom3).
21 Note that this class implements also a very simple generator (linear congruential) with periodicity = 10**9
22 which is known to have defects (the lower random bits are correlated)
23 and therefore should NOT be used in any statistical study.
24 One should use instead TRandom1, TRandom2 or TRandom3.
25 TRandom3, is based on the "Mersenne Twister generator", and is the recommended one,
26 since it has good random proprieties (period of about 10**6000 ) and it is fast.
27 TRandom1, based on the RANLUX algorithm, has mathematically proven random proprieties
28 and a period of about 10**171. It is however slower than the others.
29 TRandom2, is based on the Tausworthe generator of L'Ecuyer, and it has the advantage
30 of being fast and using only 3 words (of 32 bits) for the state. The period is 10**26.
31 
32 The following table shows some timings (in nanoseconds/call)
33 for the random numbers obtained using an Intel Pentium 3.0 GHz running Linux
34 and using the gcc 3.2.3 compiler
35 
36 - TRandom 34 ns/call (BAD Generator)
37 - TRandom1 242 ns/call
38 - TRandom2 37 ns/call
39 - TRandom3 45 ns/call
40 
41 
42 The following methods are provided to generate random numbers disctributed according to some basic distributions:
43 
44 - `Exp(tau)`
45 - `Integer(imax)`
46 - `Gaus(mean,sigma)`
47 - `Rndm()`
48 - `Uniform(x1)`
49 - `Landau(mpv,sigma)`
50 - `Poisson(mean)`
51 - `Binomial(ntot,prob)`
52 
53 Random numbers distributed according to 1-d, 2-d or 3-d distributions contained in TF1, TF2 or TF3 objects can also be generated.
54 For example, to get a random number distributed following abs(sin(x)/x)*sqrt(x)
55 you can do :
56 \code{.cpp}
57  TF1 *f1 = new TF1("f1","abs(sin(x)/x)*sqrt(x)",0,10);
58  double r = f1->GetRandom();
59 \endcode
60 or you can use the UNURAN package. You need in this case to initialize UNURAN
61 to the function you would like to generate.
62 \code{.cpp}
63  TUnuran u;
64  u.Init(TUnuranDistrCont(f1));
65  double r = u.Sample();
66 \endcode
67 
68 The techniques of using directly a TF1,2 or 3 function is powerful and
69 can be used to generate numbers in the defined range of the function.
70 Getting a number from a TF1,2,3 function is also quite fast.
71 UNURAN is a powerful and flexible tool which containes various methods for
72 generate random numbers for continuous distributions of one and multi-dimension.
73 It requires some set-up (initialization) phase and can be very fast when the distribution
74 parameters are not changed for every call.
75 
76 The following table shows some timings (in nanosecond/call)
77 for basic functions, TF1 functions and using UNURAN obtained running
78 the tutorial math/testrandom.C
79 Numbers have been obtained on an Intel Xeon Quad-core Harpertown (E5410) 2.33 GHz running
80 Linux SLC4 64 bit and compiled with gcc 3.4
81 
82 ~~~~
83 Distribution nanoseconds/call
84  TRandom TRandom1 TRandom2 TRandom3
85 Rndm.............. 5.000 105.000 7.000 10.000
86 RndmArray......... 4.000 104.000 6.000 9.000
87 Gaus.............. 36.000 180.000 40.000 48.000
88 Rannor............ 118.000 220.000 120.000 124.000
89 Landau............ 22.000 123.000 26.000 31.000
90 Exponential....... 93.000 198.000 98.000 104.000
91 Binomial(5,0.5)... 30.000 548.000 46.000 65.000
92 Binomial(15,0.5).. 75.000 1615.000 125.000 178.000
93 Poisson(3)........ 96.000 494.000 109.000 125.000
94 Poisson(10)....... 138.000 1236.000 165.000 203.000
95 Poisson(70)....... 818.000 1195.000 835.000 844.000
96 Poisson(100)...... 837.000 1218.000 849.000 864.000
97 GausTF1........... 83.000 180.000 87.000 88.000
98 LandauTF1......... 80.000 180.000 83.000 86.000
99 GausUNURAN........ 40.000 139.000 41.000 44.000
100 PoissonUNURAN(10). 85.000 271.000 92.000 102.000
101 PoissonUNURAN(100) 62.000 256.000 69.000 78.000
102 ~~~~
103 
104 Note that the time to generate a number from an arbitrary TF1 function
105 using TF1::GetRandom or using TUnuran is independent of the complexity of the function.
106 
107 TH1::FillRandom(TH1 *) or TH1::FillRandom(const char *tf1name)
108 can be used to fill an histogram (1-d, 2-d, 3-d from an existing histogram
109 or from an existing function.
110 
111 Note this interesting feature when working with objects.
112  You can use several TRandom objects, each with their "independent"
113  random sequence. For example, one can imagine
114 ~~~~
115  TRandom *eventGenerator = new TRandom();
116  TRandom *tracking = new TRandom();
117 ~~~~
118  `eventGenerator` can be used to generate the event kinematics.
119  tracking can be used to track the generated particles with random numbers
120  independent from eventGenerator.
121  This very interesting feature gives the possibility to work with simple
122  and very fast random number generators without worrying about
123  random number periodicity as it was the case with Fortran.
124  One can use TRandom::SetSeed to modify the seed of one generator.
125 
126 A TRandom object may be written to a Root file
127 
128 - as part of another object
129 - or with its own key (example: `gRandom->Write("Random")` ) ;
130 
131 */
132 
133 #include "TROOT.h"
134 #include "TMath.h"
135 #include "TRandom.h"
136 #include "TRandom3.h"
137 #include "TSystem.h"
138 #include "TDirectory.h"
139 #include "Math/QuantFuncMathCore.h"
140 #include "TUUID.h"
141 
143 
144 ////////////////////////////////////////////////////////////////////////////////
145 /// Default constructor. For seed see SetSeed().
146 
147 TRandom::TRandom(UInt_t seed): TNamed("Random","Default Random number generator")
148 {
149  SetSeed(seed);
150 }
151 
152 ////////////////////////////////////////////////////////////////////////////////
153 /// Default destructor. Can reset gRandom to 0 if gRandom points to this
154 /// generator.
155 
157 {
158  if (gRandom == this) gRandom = 0;
159 }
160 
161 ////////////////////////////////////////////////////////////////////////////////
162 /// Generates a random integer N according to the binomial law.
163 /// Coded from Los Alamos report LA-5061-MS.
164 ///
165 /// N is binomially distributed between 0 and ntot inclusive
166 /// with mean prob*ntot and prob is between 0 and 1.
167 ///
168 /// Note: This function should not be used when ntot is large (say >100).
169 /// The normal approximation is then recommended instead
170 /// (with mean =*ntot+0.5 and standard deviation sqrt(ntot*prob*(1-prob)).
171 
173 {
174  if (prob < 0 || prob > 1) return 0;
175  Int_t n = 0;
176  for (Int_t i=0;i<ntot;i++) {
177  if (Rndm() > prob) continue;
178  n++;
179  }
180  return n;
181 }
182 
183 ////////////////////////////////////////////////////////////////////////////////
184 /// Return a number distributed following a BreitWigner function with mean and gamma.
185 
187 {
188  Double_t rval, displ;
189  rval = 2*Rndm() - 1;
190  displ = 0.5*gamma*TMath::Tan(rval*TMath::PiOver2());
191 
192  return (mean+displ);
193 }
194 
195 ////////////////////////////////////////////////////////////////////////////////
196 /// Generates random vectors, uniformly distributed over a circle of given radius.
197 /// Input : r = circle radius
198 /// Output: x,y a random 2-d vector of length r
199 
201 {
202  Double_t phi = Uniform(0,TMath::TwoPi());
203  x = r*TMath::Cos(phi);
204  y = r*TMath::Sin(phi);
205 }
206 
207 ////////////////////////////////////////////////////////////////////////////////
208 /// Returns an exponential deviate.
209 ///
210 /// exp( -t/tau )
211 
213 {
214  Double_t x = Rndm(); // uniform on ] 0, 1 ]
215  Double_t t = -tau * TMath::Log( x ); // convert to exponential distribution
216  return t;
217 }
218 
219 ////////////////////////////////////////////////////////////////////////////////
220 /// Samples a random number from the standard Normal (Gaussian) Distribution
221 /// with the given mean and sigma.
222 /// Uses the Acceptance-complement ratio from W. Hoermann and G. Derflinger
223 /// This is one of the fastest existing method for generating normal random variables.
224 /// It is a factor 2/3 faster than the polar (Box-Muller) method used in the previous
225 /// version of TRandom::Gaus. The speed is comparable to the Ziggurat method (from Marsaglia)
226 /// implemented for example in GSL and available in the MathMore library.
227 ///
228 /// REFERENCE: - W. Hoermann and G. Derflinger (1990):
229 /// The ACR Method for generating normal random variables,
230 /// OR Spektrum 12 (1990), 181-185.
231 ///
232 /// Implementation taken from
233 /// UNURAN (c) 2000 W. Hoermann & J. Leydold, Institut f. Statistik, WU Wien
234 
236 {
237  const Double_t kC1 = 1.448242853;
238  const Double_t kC2 = 3.307147487;
239  const Double_t kC3 = 1.46754004;
240  const Double_t kD1 = 1.036467755;
241  const Double_t kD2 = 5.295844968;
242  const Double_t kD3 = 3.631288474;
243  const Double_t kHm = 0.483941449;
244  const Double_t kZm = 0.107981933;
245  const Double_t kHp = 4.132731354;
246  const Double_t kZp = 18.52161694;
247  const Double_t kPhln = 0.4515827053;
248  const Double_t kHm1 = 0.516058551;
249  const Double_t kHp1 = 3.132731354;
250  const Double_t kHzm = 0.375959516;
251  const Double_t kHzmp = 0.591923442;
252  /*zhm 0.967882898*/
253 
254  const Double_t kAs = 0.8853395638;
255  const Double_t kBs = 0.2452635696;
256  const Double_t kCs = 0.2770276848;
257  const Double_t kB = 0.5029324303;
258  const Double_t kX0 = 0.4571828819;
259  const Double_t kYm = 0.187308492 ;
260  const Double_t kS = 0.7270572718 ;
261  const Double_t kT = 0.03895759111;
262 
264  Double_t rn,x,y,z;
265 
266  do {
267  y = Rndm();
268 
269  if (y>kHm1) {
270  result = kHp*y-kHp1; break; }
271 
272  else if (y<kZm) {
273  rn = kZp*y-1;
274  result = (rn>0) ? (1+rn) : (-1+rn);
275  break;
276  }
277 
278  else if (y<kHm) {
279  rn = Rndm();
280  rn = rn-1+rn;
281  z = (rn>0) ? 2-rn : -2-rn;
282  if ((kC1-y)*(kC3+TMath::Abs(z))<kC2) {
283  result = z; break; }
284  else {
285  x = rn*rn;
286  if ((y+kD1)*(kD3+x)<kD2) {
287  result = rn; break; }
288  else if (kHzmp-y<exp(-(z*z+kPhln)/2)) {
289  result = z; break; }
290  else if (y+kHzm<exp(-(x+kPhln)/2)) {
291  result = rn; break; }
292  }
293  }
294 
295  while (1) {
296  x = Rndm();
297  y = kYm * Rndm();
298  z = kX0 - kS*x - y;
299  if (z>0)
300  rn = 2+y/x;
301  else {
302  x = 1-x;
303  y = kYm-y;
304  rn = -(2+y/x);
305  }
306  if ((y-kAs+x)*(kCs+x)+kBs<0) {
307  result = rn; break; }
308  else if (y<x+kT)
309  if (rn*rn<4*(kB-log(x))) {
310  result = rn; break; }
311  }
312  } while(0);
313 
314  return mean + sigma * result;
315 }
316 
317 ////////////////////////////////////////////////////////////////////////////////
318 /// Returns a random integer on [ 0, imax-1 ].
319 
321 {
322  UInt_t ui;
323  ui = (UInt_t)(imax*Rndm());
324  return ui;
325 }
326 
327 ////////////////////////////////////////////////////////////////////////////////
328 /// Generate a random number following a Landau distribution
329 /// with location parameter mu and scale parameter sigma:
330 /// Landau( (x-mu)/sigma )
331 /// Note that mu is not the mpv(most probable value) of the Landa distribution
332 /// and sigma is not the standard deviation of the distribution which is not defined.
333 /// For mu =0 and sigma=1, the mpv = -0.22278
334 ///
335 /// The Landau random number generation is implemented using the
336 /// function landau_quantile(x,sigma), which provides
337 /// the inverse of the landau cumulative distribution.
338 /// landau_quantile has been converted from CERNLIB ranlan(G110).
339 
341 {
342  if (sigma <= 0) return 0;
343  Double_t x = Rndm();
344  Double_t res = mu + ROOT::Math::landau_quantile(x, sigma);
345  return res;
346 }
347 
348 ////////////////////////////////////////////////////////////////////////////////
349 /// Generates a random integer N according to a Poisson law.
350 /// Prob(N) = exp(-mean)*mean^N/Factorial(N)
351 ///
352 /// Use a different procedure according to the mean value.
353 /// The algorithm is the same used by CLHEP.
354 /// For lower value (mean < 25) use the rejection method based on
355 /// the exponential.
356 /// For higher values use a rejection method comparing with a Lorentzian
357 /// distribution, as suggested by several authors.
358 /// This routine since is returning 32 bits integer will not work for values
359 /// larger than 2*10**9.
360 /// One should then use the Trandom::PoissonD for such large values.
361 
363 {
364  Int_t n;
365  if (mean <= 0) return 0;
366  if (mean < 25) {
367  Double_t expmean = TMath::Exp(-mean);
368  Double_t pir = 1;
369  n = -1;
370  while(1) {
371  n++;
372  pir *= Rndm();
373  if (pir <= expmean) break;
374  }
375  return n;
376  }
377  // for large value we use inversion method
378  else if (mean < 1E9) {
379  Double_t em, t, y;
380  Double_t sq, alxm, g;
381  Double_t pi = TMath::Pi();
382 
383  sq = TMath::Sqrt(2.0*mean);
384  alxm = TMath::Log(mean);
385  g = mean*alxm - TMath::LnGamma(mean + 1.0);
386 
387  do {
388  do {
389  y = TMath::Tan(pi*Rndm());
390  em = sq*y + mean;
391  } while( em < 0.0 );
392 
393  em = TMath::Floor(em);
394  t = 0.9*(1.0 + y*y)* TMath::Exp(em*alxm - TMath::LnGamma(em + 1.0) - g);
395  } while( Rndm() > t );
396 
397  return static_cast<Int_t> (em);
398 
399  }
400  else {
401  // use Gaussian approximation vor very large values
402  n = Int_t(Gaus(0,1)*TMath::Sqrt(mean) + mean +0.5);
403  return n;
404  }
405 }
406 
407 ////////////////////////////////////////////////////////////////////////////////
408 /// Generates a random number according to a Poisson law.
409 /// Prob(N) = exp(-mean)*mean^N/Factorial(N)
410 ///
411 /// This function is a variant of TRandom::Poisson returning a double
412 /// instead of an integer.
413 
415 {
416  Int_t n;
417  if (mean <= 0) return 0;
418  if (mean < 25) {
419  Double_t expmean = TMath::Exp(-mean);
420  Double_t pir = 1;
421  n = -1;
422  while(1) {
423  n++;
424  pir *= Rndm();
425  if (pir <= expmean) break;
426  }
427  return static_cast<Double_t>(n);
428  }
429  // for large value we use inversion method
430  else if (mean < 1E9) {
431  Double_t em, t, y;
432  Double_t sq, alxm, g;
433  Double_t pi = TMath::Pi();
434 
435  sq = TMath::Sqrt(2.0*mean);
436  alxm = TMath::Log(mean);
437  g = mean*alxm - TMath::LnGamma(mean + 1.0);
438 
439  do {
440  do {
441  y = TMath::Tan(pi*Rndm());
442  em = sq*y + mean;
443  } while( em < 0.0 );
444 
445  em = TMath::Floor(em);
446  t = 0.9*(1.0 + y*y)* TMath::Exp(em*alxm - TMath::LnGamma(em + 1.0) - g);
447  } while( Rndm() > t );
448 
449  return em;
450 
451  } else {
452  // use Gaussian approximation vor very large values
453  return Gaus(0,1)*TMath::Sqrt(mean) + mean +0.5;
454  }
455 }
456 
457 ////////////////////////////////////////////////////////////////////////////////
458 /// Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
459 
461 {
462  Double_t r, x, y, z;
463 
464  y = Rndm();
465  z = Rndm();
466  x = z * 6.28318530717958623;
467  r = TMath::Sqrt(-2*TMath::Log(y));
468  a = (Float_t)(r * TMath::Sin(x));
469  b = (Float_t)(r * TMath::Cos(x));
470 }
471 
472 ////////////////////////////////////////////////////////////////////////////////
473 /// Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
474 
476 {
477  Double_t r, x, y, z;
478 
479  y = Rndm();
480  z = Rndm();
481  x = z * 6.28318530717958623;
482  r = TMath::Sqrt(-2*TMath::Log(y));
483  a = r * TMath::Sin(x);
484  b = r * TMath::Cos(x);
485 }
486 
487 ////////////////////////////////////////////////////////////////////////////////
488 /// Reads saved random generator status from filename.
489 
490 void TRandom::ReadRandom(const char *filename)
491 {
492  if (!gDirectory) return;
493  char *fntmp = gSystem->ExpandPathName(filename);
494  TDirectory *file = (TDirectory*)gROOT->ProcessLine(Form("TFile::Open(\"%s\");",fntmp));
495  delete [] fntmp;
496  if(file && file->GetFile()) {
497  gDirectory->ReadTObject(this,GetName());
498  delete file;
499  }
500 }
501 
502 ////////////////////////////////////////////////////////////////////////////////
503 /// Machine independent random number generator.
504 /// Based on the BSD Unix (Rand) Linear congrential generator.
505 /// Produces uniformly-distributed floating points between 0 and 1.
506 /// Identical sequence on all machines of >= 32 bits.
507 /// Periodicity = 2**31, generates a number in (0,1).
508 /// Note that this is a generator which is known to have defects
509 /// (the lower random bits are correlated) and therefore should NOT be
510 /// used in any statistical study).
511 
513 {
514 #ifdef OLD_TRANDOM_IMPL
515  const Double_t kCONS = 4.6566128730774E-10;
516  const Int_t kMASK24 = 2147483392;
517 
518  fSeed *= 69069;
519  UInt_t jy = (fSeed&kMASK24); // Set lower 8 bits to zero to assure exact float
520  if (jy) return kCONS*jy;
521  return Rndm();
522 #endif
523 
524  // kCONS = 1./2147483648 = 1./(RAND_MAX+1) and RAND_MAX= 0x7fffffffUL
525  const Double_t kCONS = 4.6566128730774E-10; // (1/pow(2,31)
526  fSeed = (1103515245 * fSeed + 12345) & 0x7fffffffUL;
527 
528  if (fSeed) return kCONS*fSeed;
529  return Rndm();
530 }
531 
532 ////////////////////////////////////////////////////////////////////////////////
533 /// Return an array of n random numbers uniformly distributed in ]0,1].
534 
536 {
537  const Double_t kCONS = 4.6566128730774E-10; // (1/pow(2,31))
538  Int_t i=0;
539  while (i<n) {
540  fSeed = (1103515245 * fSeed + 12345) & 0x7fffffffUL;
541  if (fSeed) {array[i] = kCONS*fSeed; i++;}
542  }
543 }
544 
545 ////////////////////////////////////////////////////////////////////////////////
546 /// Return an array of n random numbers uniformly distributed in ]0,1].
547 
549 {
550  const Double_t kCONS = 4.6566128730774E-10; // (1/pow(2,31))
551  Int_t i=0;
552  while (i<n) {
553  fSeed = (1103515245 * fSeed + 12345) & 0x7fffffffUL;
554  if (fSeed) {array[i] = Float_t(kCONS*fSeed); i++;}
555  }
556 }
557 
558 ////////////////////////////////////////////////////////////////////////////////
559 /// Set the random generator seed. Note that default value is zero, which is
560 /// different than the default value used when constructing the class.
561 /// If the seed is zero the seed is set to a random value
562 /// which in case of TRandom depends on the lowest 4 bytes of TUUID
563 /// The UUID will be identical if SetSeed(0) is called with time smaller than 100 ns
564 /// Instead if a different generator implementation is used (TRandom1, 2 or 3)
565 /// the seed is generated using a 128 bit UUID. This results in different seeds
566 /// and then random sequence for every SetSeed(0) call.
567 
569 {
570  if( seed==0 ) {
571  TUUID u;
572  UChar_t uuid[16];
573  u.GetUUID(uuid);
574  fSeed = UInt_t(uuid[3])*16777216 + UInt_t(uuid[2])*65536 + UInt_t(uuid[1])*256 + UInt_t(uuid[0]);
575  } else {
576  fSeed = seed;
577  }
578 }
579 
580 ////////////////////////////////////////////////////////////////////////////////
581 /// Generates random vectors, uniformly distributed over the surface
582 /// of a sphere of given radius.
583 /// Input : r = sphere radius
584 /// Output: x,y,z a random 3-d vector of length r
585 /// Method: (based on algorithm suggested by Knuth and attributed to Robert E Knop)
586 /// which uses less random numbers than the CERNLIB RN23DIM algorithm
587 
589 {
590  Double_t a=0,b=0,r2=1;
591  while (r2 > 0.25) {
592  a = Rndm() - 0.5;
593  b = Rndm() - 0.5;
594  r2 = a*a + b*b;
595  }
596  z = r* ( -1. + 8.0 * r2 );
597 
598  Double_t scale = 8.0 * r * TMath::Sqrt(0.25 - r2);
599  x = a*scale;
600  y = b*scale;
601 }
602 
603 ////////////////////////////////////////////////////////////////////////////////
604 /// Returns a uniform deviate on the interval (0, x1).
605 
607 {
608  Double_t ans = Rndm();
609  return x1*ans;
610 }
611 
612 ////////////////////////////////////////////////////////////////////////////////
613 /// Returns a uniform deviate on the interval (x1, x2).
614 
616 {
617  Double_t ans= Rndm();
618  return x1 + (x2-x1)*ans;
619 }
620 
621 ////////////////////////////////////////////////////////////////////////////////
622 /// Writes random generator status to filename.
623 
624 void TRandom::WriteRandom(const char *filename) const
625 {
626  if (!gDirectory) return;
627  char *fntmp = gSystem->ExpandPathName(filename);
628  TDirectory *file = (TDirectory*)gROOT->ProcessLine(Form("TFile::Open(\"%s\",\"recreate\");",fntmp));
629  delete [] fntmp;
630  if(file && file->GetFile()) {
631  gDirectory->WriteTObject(this,GetName());
632  delete file;
633  }
634 }
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
XYZVector ans(TestRotation const &t, XYZVector const &v_in)
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
Definition: TRandom.cxx:460
virtual Double_t PoissonD(Double_t mean)
Generates a random number according to a Poisson law.
Definition: TRandom.cxx:414
Double_t Floor(Double_t x)
Definition: TMath.h:600
Double_t Log(Double_t x)
Definition: TMath.h:649
const double pi
float Float_t
Definition: RtypesCore.h:53
virtual Int_t Binomial(Int_t ntot, Double_t prob)
Generates a random integer N according to the binomial law.
Definition: TRandom.cxx:172
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Definition: TRandom.cxx:235
constexpr Double_t TwoPi()
Definition: TMath.h:44
virtual void RndmArray(Int_t n, Float_t *array)
Return an array of n random numbers uniformly distributed in ]0,1].
Definition: TRandom.cxx:548
virtual ~TRandom()
Default destructor.
Definition: TRandom.cxx:156
#define gROOT
Definition: TROOT.h:375
int Int_t
Definition: RtypesCore.h:41
TArc * a
Definition: textangle.C:12
Short_t Abs(Short_t d)
Definition: TMathBase.h:108
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
Definition: TUUID.h:42
static const double x2[5]
Double_t x[n]
Definition: legend1.C:17
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t tau
Definition: TRolke.cxx:630
you should not use this method at all Int_t Int_t Double_t Double_t em
Definition: TRolke.cxx:630
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
Definition: TRandom.cxx:568
virtual UInt_t Integer(UInt_t imax)
Returns a random integer on [ 0, imax-1 ].
Definition: TRandom.cxx:320
const Double_t sigma
constexpr Double_t Pi()
Definition: TMath.h:40
virtual TFile * GetFile() const
Definition: TDirectory.h:145
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandom.cxx:512
double gamma(double x)
TRandom2 r(17)
R__EXTERN TSystem * gSystem
Definition: TSystem.h:539
unsigned int UInt_t
Definition: RtypesCore.h:42
char * Form(const char *fmt,...)
virtual void WriteRandom(const char *filename) const
Writes random generator status to filename.
Definition: TRandom.cxx:624
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
virtual void Circle(Double_t &x, Double_t &y, Double_t r)
Generates random vectors, uniformly distributed over a circle of given radius.
Definition: TRandom.cxx:200
Double_t Cos(Double_t)
Definition: TMath.h:551
Double_t Exp(Double_t x)
Definition: TMath.h:622
static const double x1[5]
UInt_t fSeed
Definition: TRandom.h:30
#define ClassImp(name)
Definition: Rtypes.h:336
double Double_t
Definition: RtypesCore.h:55
Describe directory structure in memory.
Definition: TDirectory.h:34
unsigned long ULong_t
Definition: RtypesCore.h:51
virtual void ReadRandom(const char *filename)
Reads saved random generator status from filename.
Definition: TRandom.cxx:490
Double_t y[n]
Definition: legend1.C:17
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Definition: TRandom.cxx:606
virtual Double_t BreitWigner(Double_t mean=0, Double_t gamma=1)
Return a number distributed following a BreitWigner function with mean and gamma. ...
Definition: TRandom.cxx:186
virtual void Sphere(Double_t &x, Double_t &y, Double_t &z, Double_t r)
Generates random vectors, uniformly distributed over the surface of a sphere of given radius...
Definition: TRandom.cxx:588
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
double landau_quantile(double z, double xi=1)
Inverse ( ) of the cumulative distribution function of the lower tail of the Landau distribution (lan...
Definition: file.py:1
Double_t Sin(Double_t)
Definition: TMath.h:548
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
Double_t LnGamma(Double_t z)
Computation of ln[gamma(z)] for all z.
Definition: TMath.cxx:489
#define gDirectory
Definition: TDirectory.h:211
double result[121]
unsigned char UChar_t
Definition: RtypesCore.h:34
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition: TSystem.cxx:1250
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
Definition: TRandom.cxx:362
Double_t Sqrt(Double_t x)
Definition: TMath.h:591
double exp(double)
virtual Double_t Landau(Double_t mean=0, Double_t sigma=1)
Generate a random number following a Landau distribution with location parameter mu and scale paramet...
Definition: TRandom.cxx:340
void GetUUID(UChar_t uuid[16]) const
Return uuid in specified buffer (16 byte = 128 bits).
Definition: TUUID.cxx:661
const Int_t n
Definition: legend1.C:16
Double_t Tan(Double_t)
Definition: TMath.h:554
constexpr Double_t PiOver2()
Definition: TMath.h:48
unsigned int r2[N_CITIES]
Definition: simanTSP.cxx:322
double log(double)
virtual Double_t Exp(Double_t tau)
Returns an exponential deviate.
Definition: TRandom.cxx:212