ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
CLHEP::RandBinomialFixedP Class Reference

#include <RandBinomialFixedP.h>

Inheritance diagram for CLHEP::RandBinomialFixedP:
Collaboration diagram for CLHEP::RandBinomialFixedP:

Public Member Functions

 RandBinomialFixedP (HepRandomEngine &anEngine, long n=1, double p=0.5, long Nmaxlookup=10)
 
 RandBinomialFixedP (HepRandomEngine *anEngine, long n=1, double p=0.5, long Nmaxlookup=10)
 
virtual ~RandBinomialFixedP ()
 
void initLookupTable (long Nmaxlookup, double p)
 
double fire ()
 
double fire (long n)
 
double fire (HepRandomEngine *anEngine, long n)
 
void fireArray (const int size, double *vect)
 
void fireArray (const int size, double *vect, long n)
 
double operator() ()
 
double operator() (long n)
 
std::string name () const
 

Static Public Member Functions

static std::string distributionName ()
 
static double shoot ()=delete
 
static double shoot (long n, double p)=delete
 
static void shootArray (const int size, double *vect, long n=1, double p=0.5)=delete
 
static double shoot (HepRandomEngine *anEngine)=delete
 
static double shoot (HepRandomEngine *anEngine, long n, double p)=delete
 
static void shootArray (HepRandomEngine *anEngine, const int size, double *vect, long n=1, double p=0.5)=delete
 

Protected Attributes

std::vector< std::vector< double > > LookupTable
 

Detailed Description

Author

Definition at line 18 of file RandBinomialFixedP.h.

Constructor & Destructor Documentation

◆ RandBinomialFixedP() [1/2]

CLHEP::RandBinomialFixedP::RandBinomialFixedP ( HepRandomEngine &  anEngine,
long  n = 1,
double  p = 0.5,
long  Nmaxlookup = 10 
)
inline

◆ RandBinomialFixedP() [2/2]

CLHEP::RandBinomialFixedP::RandBinomialFixedP ( HepRandomEngine *  anEngine,
long  n = 1,
double  p = 0.5,
long  Nmaxlookup = 10 
)
inline

◆ ~RandBinomialFixedP()

CLHEP::RandBinomialFixedP::~RandBinomialFixedP ( )
virtual

Definition at line 16 of file RandBinomialFixedP.cxx.

16  {
17 }

Member Function Documentation

◆ distributionName()

static std::string CLHEP::RandBinomialFixedP::distributionName ( )
inlinestatic

Definition at line 57 of file RandBinomialFixedP.h.

57 {return "RandBinomialFixedP";}

◆ fire() [1/3]

double CLHEP::RandBinomialFixedP::fire ( )
inline

◆ fire() [2/3]

double CLHEP::RandBinomialFixedP::fire ( HepRandomEngine *  anEngine,
long  n 
)

Definition at line 40 of file RandBinomialFixedP.cxx.

40  {
41  if(n==1) {
42  double prop=anEngine->flat();
43  if(prop>defaultP) return 0;
44  return 1;
45  }
46  if(n>(long)LookupTable.size()) return genBinomial( anEngine, n, defaultP );
47 
48  auto& table=LookupTable[n-1];
49 
50  double prop=anEngine->flat();
51  auto itk = std::upper_bound(table.begin(),table.end(),prop);
52  return std::distance(table.begin(),itk);
53 }

◆ fire() [3/3]

double CLHEP::RandBinomialFixedP::fire ( long  n)

◆ fireArray() [1/2]

void CLHEP::RandBinomialFixedP::fireArray ( const int  size,
double *  vect 
)

Definition at line 55 of file RandBinomialFixedP.cxx.

56 {
57  for( double* v = vect; v != vect+size; ++v )
58  *v = fire(defaultN);
59 }

◆ fireArray() [2/2]

void CLHEP::RandBinomialFixedP::fireArray ( const int  size,
double *  vect,
long  n 
)

Definition at line 61 of file RandBinomialFixedP.cxx.

63 {
64  for( double* v = vect; v != vect+size; ++v )
65  *v = fire(n);
66 }

◆ initLookupTable()

void CLHEP::RandBinomialFixedP::initLookupTable ( long  Nmaxlookup,
double  p 
)

Definition at line 23 of file RandBinomialFixedP.cxx.

23  {
24  defaultP=p;
25  LookupTable.resize(Nmaxlookup);
26  for(unsigned int n=1;n<=Nmaxlookup;++n) {
27  unsigned int in=n-1;
28  double q=1-p;
29  LookupTable[in].resize(n);
30  //LookupTable[in][n]=1 always, so don't need to store
31  for(unsigned int k=0;k<n;++k) {
32  //p(k;n,p)=n!/(k!*(n-k)!)*p^k*(1-p)^(n-k)
33  double prop=binom(n,k)*std::pow(p,k)*std::pow(q,n-k);
34  if(k>0) prop+=LookupTable[in][k-1];
35  LookupTable[in][k]=prop;
36  }
37  }
38 }

◆ name()

std::string CLHEP::RandBinomialFixedP::name ( ) const

Definition at line 14 of file RandBinomialFixedP.cxx.

14 {return "RandBinomialFixedP";}

◆ operator()() [1/2]

double CLHEP::RandBinomialFixedP::operator() ( )
inline

◆ operator()() [2/2]

double CLHEP::RandBinomialFixedP::operator() ( long  n)
inline

◆ shoot() [1/4]

static double CLHEP::RandBinomialFixedP::shoot ( )
staticdelete

◆ shoot() [2/4]

static double CLHEP::RandBinomialFixedP::shoot ( HepRandomEngine *  anEngine)
inlinestaticdelete

◆ shoot() [3/4]

static double CLHEP::RandBinomialFixedP::shoot ( HepRandomEngine *  anEngine,
long  n,
double  p 
)
staticdelete

◆ shoot() [4/4]

static double CLHEP::RandBinomialFixedP::shoot ( long  n,
double  p 
)
staticdelete

◆ shootArray() [1/2]

static void CLHEP::RandBinomialFixedP::shootArray ( const int  size,
double *  vect,
long  n = 1,
double  p = 0.5 
)
staticdelete

◆ shootArray() [2/2]

static void CLHEP::RandBinomialFixedP::shootArray ( HepRandomEngine *  anEngine,
const int  size,
double *  vect,
long  n = 1,
double  p = 0.5 
)
staticdelete

Member Data Documentation

◆ LookupTable

std::vector< std::vector< double > > CLHEP::RandBinomialFixedP::LookupTable
protected

Definition at line 74 of file RandBinomialFixedP.h.


The documentation for this class was generated from the following files:
CLHEP::binom
double binom(int n, int k)
Definition: RandBinomialFixedP.cxx:19
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
CLHEP::RandBinomialFixedP::LookupTable
std::vector< std::vector< double > > LookupTable
Definition: RandBinomialFixedP.h:74
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
CLHEP::RandBinomialFixedP::fire
double fire()
beamspotman.n
n
Definition: beamspotman.py:731
python.ext.table_printer.table
list table
Definition: table_printer.py:81
python.PyAthena.v
v
Definition: PyAthena.py:154
extractSporadic.q
list q
Definition: extractSporadic.py:98
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
fitman.k
k
Definition: fitman.py:528