Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
RooRandom.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooRandom.cxx
19\class RooRandom
20\ingroup Roofitcore
21
22This class provides a static interface for generating random numbers.
23By default a private copy of TRandom3 is used to generate all random numbers.
24**/
25#include <cassert>
26
27#include "RooRandom.h"
29
30#include "TRandom3.h"
31
32
33
37
38////////////////////////////////////////////////////////////////////////////////
39
42
43////////////////////////////////////////////////////////////////////////////////
44/// Return a pointer to a singleton random-number generator
45/// implementation. Creates the object the first time it is called.
46
52
53
54////////////////////////////////////////////////////////////////////////////////
55/// set the random number generator; takes ownership of the object passed as parameter
56
62
63////////////////////////////////////////////////////////////////////////////////
64/// Return a pointer to a singleton quasi-random generator
65/// implementation. Creates the object the first time it is called.
66
72
73
74////////////////////////////////////////////////////////////////////////////////
75/// Return a number uniformly distributed from (0,1)
76
78{
79 return generator->Rndm();
80}
81
82
83////////////////////////////////////////////////////////////////////////////////
84/// Fill the vector provided with random numbers uniformly distributed from (0,1)
85
86void RooRandom::uniform(UInt_t dimension, double vector[], TRandom *generator)
87{
88 generator->RndmArray(dimension, vector);
89}
90
91
92////////////////////////////////////////////////////////////////////////////////
93/// Return an integer uniformly distributed from [0,n-1]
94
96{
97 return generator->Integer(n);
98}
99
100
101////////////////////////////////////////////////////////////////////////////////
102/// Return a Gaussian random variable with mean 0 and variance 1.
103
105{
106 return generator->Gaus();
107}
108
109
110////////////////////////////////////////////////////////////////////////////////
111/// Return a quasi-random number in the range (0,1) using the
112/// Niederreiter base 2 generator described in Bratley, Fox, Niederreiter,
113/// ACM Trans. Model. Comp. Sim. 2, 195 (1992).
114
116{
117 return generator->generate(dimension,vector);
118}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
This class generates the quasi-random (aka "low discrepancy") sequence for dimensions up to 12 using ...
static RooQuasiRandomGenerator * quasiGenerator()
Return a pointer to a singleton quasi-random generator implementation.
Definition RooRandom.cxx:67
static double uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1)
Definition RooRandom.cxx:77
static double gaussian(TRandom *generator=randomGenerator())
Return a Gaussian random variable with mean 0 and variance 1.
static struct Guard guard
Definition RooRandom.h:48
static bool quasi(UInt_t dimension, double vector[], RooQuasiRandomGenerator *generator=quasiGenerator())
Return a quasi-random number in the range (0,1) using the Niederreiter base 2 generator described in ...
static TRandom * _theGenerator
random number generator
Definition RooRandom.h:43
static UInt_t integer(UInt_t max, TRandom *generator=randomGenerator())
Return an integer uniformly distributed from [0,n-1].
Definition RooRandom.cxx:95
static void setRandomGenerator(TRandom *gen)
set the random number generator; takes ownership of the object passed as parameter
Definition RooRandom.cxx:57
static RooQuasiRandomGenerator * _theQuasiGenerator
quasi random number sequence generator
Definition RooRandom.h:44
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
Definition RooRandom.cxx:47
Random number generator class based on M.
Definition TRandom3.h:27
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
const Int_t n
Definition legend1.C:16