RandGeneral


Class defining methods for shooting generally distributed random values, given a user-defined probability distribution function.

Authors

S.Magni & G.Pieri

See also

HepRandomEngine, DRand48Engine , DualRand, HepJamesRandom, Hurd160Engine, Hurd288Engine, MTwistEngine, RandEngine, RanecuEngine, RanluxEngine, Ranlux64Engine, RanshiEngine, TripleRand

Distributions: HepRandom, RandBinomial, RandBit, RandBreitWigner, RandChiSquare, RandExponential, RandFlat, RandGamma, RandGauss, RandGaussQ, RandGaussT, RandGeneral, RandLandau, RandPoisson, RandPoissonQ, RandPoissonT, RandStudentT

Functions: HepStat

Declaration

#include "CLHEP/Random/RandGeneral.h"

class RandGeneral : public HepRandom

Public Member Functions

Constructors
RandGeneral(const HepDouble* aProbFunc, HepInt theProbSize, HepInt IntType=0)
RandGeneral(HepRandomEngine& anEngine, const HepDouble* aProbFunc, HepInt theProbSize, HepInt IntType=0)
RandGeneral(HepRandomEngine* anEngine, const HepDouble* aProbFunc, HepInt theProbSize, HepInt IntType=0)
These constructors should be used to instantiate a RandGeneral distribution object defining a local engine for it.
The static generator will be skiped by using the non-static methods defined below. In case no engine is specified in the constructor, the default engine used by the static generator is applied.
If the engine is passed by pointer the corresponding engine object will be deleted by the RandGeneral destructor.
If the engine is passed by reference the corresponding engine object will not be deleted by the RandGeneral destructor.
The probability distribution function (Pdf) must be provided by the user as an array of positive real number. The array size must also be provided. The Pdf doesn't need to be normalized to 1.
If IntType = 0 (default value) a uniform random number is generated using the engine. The uniform number is then transformed to the user's distribution using the cumulative probability distribution constructed from his histogram. The cumulative distribution is inverted using a binary search for the nearest bin boundary and a linear interpolation within the bin. RandGeneral therefore generates a constant density within each bin.
If IntType = 1 no interpolation is performed and the result is a discrete distribution.
Destructor
virtual ~RandGeneral()
()
HepDouble operator()()
Method using the localEngine to shoot random values, by-passing the static generator.
fire
HepDouble fire()
Method using the localEngine to shoot random values, by-passing the static generator.
fireArray
void fireArray(const HepInt size, HepDouble* vect)
Method using the localEngine to shoot random values, by-passing the static generator.
shoot
inline HepDouble shoot()
Method to shoot random values using the static generator
N.B.: The methods are NOT static since they use nonstatic members theIntegralPdf & nBins

HepDouble shoot(HepRandomEngine* anEngine)
Method to shoot random values using a given engine by-passing the static generator.
shootArray
inline void shootArray(const HepInt size, HepDouble* vect)
Method to shoot random values using the static generator
N.B.: The methods are NOT static since they use nonstatic members theIntegralPdf & nBins

void shootArray(HepRandomEngine* anEngine, const HepInt size, HepDouble* vect)
Method to shoot random values using a given engine by-passing the static generator.

Example

CLHEP/test/testRandom.cc


17 May 2000
EVC