shark::Binomial< RngType > Class Template Reference

Models a binomial distribution with parameters p and n. More...

#include <shark/Rng/Binomial.h>

+ Inheritance diagram for shark::Binomial< RngType >:

Public Member Functions

 Binomial (RngType &rng, unsigned int n=1, double prob=0.5)
 C'tor, initializes parameters n and p, initializes for a custom RNG. More...
 
long operator() (unsigned int n, double prob)
 Samples a random number from the distribution with parameter n and p. More...
 
double prob () const
 Accesses the parameter p of the distirbution. More...
 
void prob (double newProb)
 Adjusts the parameter p of the distribution. More...
 
unsigned int n () const
 Accesses the parameter n of the distribution. More...
 
void n (unsigned int newN)
 Adjusts the parameter n of the distribution. More...
 
double p (long k) const
 Implements the pmf of the distribution. More...
 

Detailed Description

template<typename RngType = shark::DefaultRngType>
class shark::Binomial< RngType >

Models a binomial distribution with parameters p and n.

Definition at line 49 of file Binomial.h.

Constructor & Destructor Documentation

◆ Binomial()

template<typename RngType = shark::DefaultRngType>
shark::Binomial< RngType >::Binomial ( RngType &  rng,
unsigned int  n = 1,
double  prob = 0.5 
)
inline

C'tor, initializes parameters n and p, initializes for a custom RNG.

Parameters
[in,out]rngThe random number generator.
[in]nParameter n.descibing the number of coin tosses
[in]probParameter p.

Definition at line 60 of file Binomial.h.

Member Function Documentation

◆ n() [1/2]

template<typename RngType = shark::DefaultRngType>
unsigned int shark::Binomial< RngType >::n ( ) const
inline

Accesses the parameter n of the distribution.

Definition at line 94 of file Binomial.h.

Referenced by shark::Binomial< RngType >::p(), and shark::Binomial< RngType >::prob().

◆ n() [2/2]

template<typename RngType = shark::DefaultRngType>
void shark::Binomial< RngType >::n ( unsigned int  newN)
inline

Adjusts the parameter n of the distribution.

Definition at line 101 of file Binomial.h.

References shark::Binomial< RngType >::prob().

◆ operator()()

template<typename RngType = shark::DefaultRngType>
long shark::Binomial< RngType >::operator() ( unsigned int  n,
double  prob 
)
inline

Samples a random number from the distribution with parameter n and p.

Definition at line 72 of file Binomial.h.

◆ p()

template<typename RngType = shark::DefaultRngType>
double shark::Binomial< RngType >::p ( long  k) const
inline

Implements the pmf of the distribution.

Parameters
[in]kNumber of successful trials.
Returns
The probability of k successful in n total trials.
Exceptions
std::overflow_errorif the result is too large to be represented in type double.

Definition at line 111 of file Binomial.h.

References shark::Binomial< RngType >::n(), and shark::Binomial< RngType >::prob().

◆ prob() [1/2]

template<typename RngType = shark::DefaultRngType>
double shark::Binomial< RngType >::prob ( ) const
inline

Accesses the parameter p of the distirbution.

Definition at line 80 of file Binomial.h.

Referenced by shark::Binomial< RngType >::n(), and shark::Binomial< RngType >::p().

◆ prob() [2/2]

template<typename RngType = shark::DefaultRngType>
void shark::Binomial< RngType >::prob ( double  newProb)
inline

Adjusts the parameter p of the distribution.

Definition at line 87 of file Binomial.h.

References shark::Binomial< RngType >::n().


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