hep-mc  0.8
Public Member Functions | List of all members
hep::vegas_pdf< T > Class Template Reference

Detailed Description

template<typename T>
class hep::vegas_pdf< T >

A class for generating random numbers according to a piecewise constant probability distribution function with varying bin widths. The PDF generates random numbers for any dimension by using a separable pdf, i.e. for \( n \)-dimensions the PDF is

\[ p \left( x_1, x_2, \ldots, x_n \right) = \prod_{i=1}^n p_i \left( x_i \right) \]

with \( n \) different piecewise constant one-dimensional PDFs \( p_i \left( x_i \right) \). The value of the PDF is determined by the inverse size of the bins. The bin boundaries \( x_i \) can be accessed by the member function bin_left and set by set_bin_left. The boundaries need to satisfy the consistency condition

\[ 0 = x_0 < x_1 < \ldots < x_{n-1} < x_n = 1 \]

Examples:
vegas_read_pdf.cpp.

Public Member Functions

 vegas_pdf (std::size_t dimensions, std::size_t bins)
 
 vegas_pdf (std::istream &in)
 
bin_left (std::size_t dimension, std::size_t bin) const
 
void set_bin_left (std::size_t dimension, std::size_t bin, T left)
 
std::size_t bins () const
 
std::size_t dimensions () const
 
void serialize (std::ostream &out) const
 

Constructor & Destructor Documentation

◆ vegas_pdf() [1/2]

template<typename T>
hep::vegas_pdf< T >::vegas_pdf ( std::size_t  dimensions,
std::size_t  bins 
)
inline

Constructor. Constructs a piecewise constant PDF with the given dimensions, each dimension subdivided by given number of bins. Initialy each bin has the same size and therefore this PDF generates uniformly distributed random numbers.

◆ vegas_pdf() [2/2]

template<typename T>
hep::vegas_pdf< T >::vegas_pdf ( std::istream &  in)
inlineexplicit

Deserialization constructor.

Member Function Documentation

◆ bin_left()

template<typename T>
T hep::vegas_pdf< T >::bin_left ( std::size_t  dimension,
std::size_t  bin 
) const
inline

Returns the left bin boundary of bin in dimension.

◆ bins()

template<typename T>
std::size_t hep::vegas_pdf< T >::bins ( ) const
inline

The number of bins for each dimension.

◆ dimensions()

template<typename T>
std::size_t hep::vegas_pdf< T >::dimensions ( ) const
inline

The number of dimensions of this PDF.

◆ serialize()

template<typename T>
void hep::vegas_pdf< T >::serialize ( std::ostream &  out) const
inline

Serializes this object.

◆ set_bin_left()

template<typename T>
void hep::vegas_pdf< T >::set_bin_left ( std::size_t  dimension,
std::size_t  bin,
left 
)
inline

Places the new left boundary of bin in dimension at left. Note that this function does not try to maintain an internally consistent state, i.e. if you use this function make sure the first entry is zero, the last one and all entries in between are strictly increasing.