pf
pf::rvsamp::BernSampler< float_t, int_t > Class Template Reference

A class that performs sampling from a univariate Bernoulli distribution. More...

#include <rv_samp.h>

Inheritance diagram for pf::rvsamp::BernSampler< float_t, int_t >:
Collaboration diagram for pf::rvsamp::BernSampler< float_t, int_t >:

Public Member Functions

 BernSampler ()
 Default-constructor sets up for Bernoulli random variate generation with p = .5.
 
 BernSampler (float_t p)
 Constructs Bernoulli sampler with user-specified p. More...
 
void setP (float_t p)
 sets the parameter p. More...
 
int_t sample ()
 Draws a random number. More...
 
- Public Member Functions inherited from pf::rvsamp::rvsamp_base
 rvsamp_base ()
 The default constructor. This is the only option available. Sets the seed with the clock.
 

Private Attributes

std::bernoulli_distribution m_B_gen
 makes normal random variates
 
float_t m_p
 the mean
 

Additional Inherited Members

- Protected Attributes inherited from pf::rvsamp::rvsamp_base
std::mt19937 m_rng
 prng
 

Detailed Description

template<typename float_t, typename int_t>
class pf::rvsamp::BernSampler< float_t, int_t >

A class that performs sampling from a univariate Bernoulli distribution.

Author
taylor

Constructor & Destructor Documentation

◆ BernSampler()

template<typename float_t , typename int_t >
pf::rvsamp::BernSampler< float_t, int_t >::BernSampler ( float_t  p)

Constructs Bernoulli sampler with user-specified p.

Parameters
pa float_t for the probability that the rv equals 1.

Member Function Documentation

◆ sample()

template<typename float_t , typename int_t >
int_t pf::rvsamp::BernSampler< float_t, int_t >::sample

Draws a random number.

Returns
a random sample of type int_t.

◆ setP()

template<typename float_t , typename int_t >
void pf::rvsamp::BernSampler< float_t, int_t >::setP ( float_t  p)

sets the parameter p.

Parameters
pthe p(X=1) = 1-p(X=0).

The documentation for this class was generated from the following file: