Randomly sample discrete events with an empirical distribution.
More...
#include <gsl_randist.h>
Randomly sample discrete events with an empirical distribution.
This is an RAII wrapper on the GNU GSL code to support sampling from an empiricallydefined distribution of discrete events.
 Exceptions

 See Also
 http://www.gnu.org/software/gsl/manual/html_node/GeneralDiscreteDistributions.html
kjb::Gsl_ran_discrete::Gsl_ran_discrete 
( 
size_t 
event_count, 


const double * 
event_probs 

) 
 

inline 
build the sampler from an array of event weights or probabilities
Event weights do not need to be normalized to sum to 1.
kjb::Gsl_ran_discrete::Gsl_ran_discrete 
( 
const Vector & 
event_probs  ) 


inline 
build the sampler from a Vector event weights or probabilities
Event weights do not need to be normalized to sum to 1.
kjb::Gsl_ran_discrete::Gsl_ran_discrete 
( 
const std::vector< double > & 
event_probs  ) 


inline 
build the sampler from a std::vector< double > of event weights
Event weights do not need to be normalized to sum to 1.
double kjb::Gsl_ran_discrete::pdf 
( 
size_t 
k  ) 


inline 
Recompute the probability mass (or density) for event k.
 Warning
 this is sort of an expensive operation: if you can save the original array of probabilities (or densities) that were used in the ctor, that would be quicker.
double kjb::Gsl_ran_discrete::sample 
( 
const gsl_rng * 
rng  ) 


inline 
sample from the discrete distribution
 Parameters

rng  This is a GSL random number generator pointer. I recommend that you instantiate a class such as Gsl_rng_mt19937 and pass in that object, which will be transparently converted to the correct type. To prevent correlations, you should not instantiate a new RNG object each time you sample or even each time you instantiate this class. You should minimize the number of instantiations of random number generators. 
swap the internal state of two of these objects
The documentation for this class was generated from the following file: