g4tools  5.4.0
Public Member Functions | Protected Attributes | List of all members
tools::rbinomial< FLAT, REAL, UINT > Class Template Reference

Public Member Functions

 rbinomial (FLAT &a_flat, UINT a_n=1, REAL a_p=REAL(0.5))
 
virtual ~rbinomial ()
 
 rbinomial (const rbinomial &a_from)
 
rbinomialoperator= (const rbinomial &a_from)
 
UINT shoot () const
 
FLAT & flat ()
 
void set_seed (unsigned int a_seed)
 

Protected Attributes

FLAT & m_flat
 
UINT m_n
 
REAL m_p
 

Detailed Description

template<class FLAT, class REAL, class UINT>
class tools::rbinomial< FLAT, REAL, UINT >

Definition at line 196 of file randT.

Constructor & Destructor Documentation

◆ rbinomial() [1/2]

template<class FLAT , class REAL , class UINT >
tools::rbinomial< FLAT, REAL, UINT >::rbinomial ( FLAT &  a_flat,
UINT  a_n = 1,
REAL  a_p = REAL(0.5) 
)
inline

Definition at line 198 of file randT.

198 :m_flat(a_flat),m_n(a_n),m_p(a_p){}

◆ ~rbinomial()

template<class FLAT , class REAL , class UINT >
virtual tools::rbinomial< FLAT, REAL, UINT >::~rbinomial ( )
inlinevirtual

Definition at line 199 of file randT.

199 {}

◆ rbinomial() [2/2]

template<class FLAT , class REAL , class UINT >
tools::rbinomial< FLAT, REAL, UINT >::rbinomial ( const rbinomial< FLAT, REAL, UINT > &  a_from)
inline

Definition at line 201 of file randT.

201 :m_flat(a_from.m_flat),m_n(a_from.m_n),m_p(a_from.m_p){}

Member Function Documentation

◆ flat()

template<class FLAT , class REAL , class UINT >
FLAT& tools::rbinomial< FLAT, REAL, UINT >::flat ( )
inline

Definition at line 229 of file randT.

229 {return m_flat;}

◆ operator=()

template<class FLAT , class REAL , class UINT >
rbinomial& tools::rbinomial< FLAT, REAL, UINT >::operator= ( const rbinomial< FLAT, REAL, UINT > &  a_from)
inline

Definition at line 202 of file randT.

202  {
203  m_n = a_from.m_n;
204  m_p = a_from.m_p;
205  return *this;
206  }

◆ set_seed()

template<class FLAT , class REAL , class UINT >
void tools::rbinomial< FLAT, REAL, UINT >::set_seed ( unsigned int  a_seed)
inline

Definition at line 230 of file randT.

230 {m_flat.set_seed(a_seed);}

◆ shoot()

template<class FLAT , class REAL , class UINT >
UINT tools::rbinomial< FLAT, REAL, UINT >::shoot ( ) const
inline

Generates a random integer N according to the binomial law. Coded from Los Alamos report LA-5061-MS.

N is binomially distributed between 0 and ntot inclusive with mean prob*ntot and prob is between 0 and 1.

Note: This function should not be used when ntot is large (say >100). The normal approximation is then recommended instead (with mean =*ntot+0.5 and standard deviation sqrt(ntot*prob*(1-prob)).

Definition at line 208 of file randT.

208  {
209  // from ROOT/TRandom.cxx.
221  if((m_p<REAL(0))||(REAL(1)<m_p)) return 0;
222  UINT n = 0;
223  for(UINT i=0;i<m_n;i++) {
224  if(m_flat.shoot()>m_p) continue;
225  n++;
226  }
227  return n;
228  }

Member Data Documentation

◆ m_flat

template<class FLAT , class REAL , class UINT >
FLAT& tools::rbinomial< FLAT, REAL, UINT >::m_flat
protected

Definition at line 232 of file randT.

◆ m_n

template<class FLAT , class REAL , class UINT >
UINT tools::rbinomial< FLAT, REAL, UINT >::m_n
protected

Definition at line 233 of file randT.

◆ m_p

template<class FLAT , class REAL , class UINT >
REAL tools::rbinomial< FLAT, REAL, UINT >::m_p
protected

Definition at line 234 of file randT.


The documentation for this class was generated from the following file:
tools::rbinomial::m_flat
FLAT & m_flat
Definition: randT:232
tools::rbinomial::m_n
UINT m_n
Definition: randT:233
tools::rbinomial::m_p
REAL m_p
Definition: randT:234