STK++ 0.9.13
STK::Law::NegativeBinomial Class Reference

NegativeBinomial probability law. More...

#include <STK_Law_NegativeBinomial.h>

Inheritance diagram for STK::Law::NegativeBinomial:
Inheritance graph

Public Types

typedef IUnivLaw< IntegerBase
 

Public Member Functions

 NegativeBinomial (int size=1, Real const &prob=0.5)
 constructor
 
virtual ~NegativeBinomial ()
 destructor
 
Real constprob () const
 
int size () const
 
void setProb (Real const &prob)
 
void setSize (Integer size)
 
virtual Integer rand () const
 
virtual Real cdf (Real const &t) const
 compute the cumulative distribution function Give the probability that a NegativeBinomial random variate is less or equal to t.
 
virtual Real pdf (Integer const &x) const
 compute the probability distribution function (density) Give the value of the pdf at the point x.
 
virtual Real lpdf (Integer const &x) const
 compute the log probability distribution function Give the value of the log-pdf at the point x.
 
virtual Integer icdf (Real const &p) const
 inverse cumulative distribution function The quantile is defined as the smallest value x such that F(x) >= p , where F is the cumulative distribution function.
 
- Public Member Functions inherited from STK::Law::IUnivLaw< Integer >
virtual ~IUnivLaw ()
 Virtual destructor.
 
virtual Real lcdf (Real const &t) const
 compute the lower tail log-cumulative distribution function Give the log-probability that a random variate is less or equal to t.
 
virtual Real cdfc (Real const &t) const
 calculate the complement of cumulative distribution function, called in statistics the survival function.
 
virtual Real lcdfc (Real const &t) const
 calculate the log-complement of cumulative distribution function Give the log-probability that a random variate is greater than t.
 
- Public Member Functions inherited from STK::Law::ILawBase
String constname () const
 

Static Public Member Functions

static Integer rand (int size, Real const &prob)
 
static Real pdf (Integer x, int size, Real const &prob)
 compute the probability distribution function (density) Give the value of the pdf at the point x.
 
static Real lpdf (Integer x, int size, Real const &prob)
 compute the log probability distribution function Give the value of the log-pdf at the point x.
 
static Real cdf (Real const &t, int size, Real const &prob)
 compute the cumulative distribution function Give the value of the cdf at the point t.
 
static Integer icdf (Real const &p, int size, Real const &prob)
 inverse cumulative distribution function The quantile is defined as the smallest value x such that F(x) >= p , where F is the cumulative distribution function.
 

Protected Attributes

int size_
 number of successes
 
Real prob_
 probability of success in a Bernoulli trial
 
- Protected Attributes inherited from STK::Law::ILawBase
String name_
 Name of the Law.
 

Additional Inherited Members

- Protected Member Functions inherited from STK::Law::IUnivLaw< Integer >
 IUnivLaw (String const &name)
 Constructor.
 
 IUnivLaw (IUnivLaw const &law)
 copy Constructor.
 
- Protected Member Functions inherited from STK::Law::ILawBase
 ILawBase (String const &name)
 Constructor.
 
 ~ILawBase ()
 destructor.
 

Detailed Description

NegativeBinomial probability law.

In probability theory and statistics, the negative binomial distribution is a discrete probability distribution of the number of successes in a sequence of independent and identically distributed Bernoulli trials before a specified (non-random) number of failures (denoted r) occurs.

Suppose there is a sequence of independent Bernoulli trials, each trial having two potential outcomes called “success” and “failure”. In each trial the probability of success is p and of failure is (1 − p). We are observing this sequence until a predefined number r of failures has occurred. Then the random number of successes we have seen, X, will have the negative binomial (or Pascal) distribution: $ X\ \sim\ \text{NB}(r; p) $

The probability mass function of the negative binomial distribution is

\[
f(k; r, p) = \Pr(X = k) = \binom{k+r-1}{k} p^k(1-p)^r \quad\text{for }
k = 0, 1, 2, \dots
\]

Definition at line 68 of file STK_Law_NegativeBinomial.h.

Member Typedef Documentation

◆ Base

Constructor & Destructor Documentation

◆ NegativeBinomial()

STK::Law::NegativeBinomial::NegativeBinomial ( int  size = 1,
Real const prob = 0.5 
)
inline

constructor

Parameters
prob,sizeprobability of success and number of successes in a NegativeBinomial trial

Definition at line 75 of file STK_Law_NegativeBinomial.h.

76 : Base(_T("Negative Binomial")), size_(size), prob_(prob) {}
#define _T(x)
Let x unmodified.
Real prob_
probability of success in a Bernoulli trial

◆ ~NegativeBinomial()

virtual STK::Law::NegativeBinomial::~NegativeBinomial ( )
inlinevirtual

destructor

Definition at line 79 of file STK_Law_NegativeBinomial.h.

79{}

Member Function Documentation

◆ cdf() [1/2]

Real STK::Law::NegativeBinomial::cdf ( Real const t) const
virtual

compute the cumulative distribution function Give the probability that a NegativeBinomial random variate is less or equal to t.

Parameters
ta real value
Returns
the value of the cdf

Implements STK::Law::IUnivLaw< Integer >.

Definition at line 76 of file STK_Law_NegativeBinomial.cpp.

77{
78 return 0;
79}

◆ cdf() [2/2]

Real STK::Law::NegativeBinomial::cdf ( Real const t,
int  size,
Real const prob 
)
static

compute the cumulative distribution function Give the value of the cdf at the point t.

Parameters
ta real value
size,probprobability of success and number of successes in a NegativeBinomial trial
Returns
the value of the cdf

Definition at line 123 of file STK_Law_NegativeBinomial.cpp.

124{
125 return 0;
126}

◆ icdf() [1/2]

Integer STK::Law::NegativeBinomial::icdf ( Real const p) const
virtual

inverse cumulative distribution function The quantile is defined as the smallest value x such that F(x) >= p , where F is the cumulative distribution function.

Parameters
pa probability number

Implements STK::Law::IUnivLaw< Integer >.

Definition at line 85 of file STK_Law_NegativeBinomial.cpp.

86{
87 return 0;
88}

◆ icdf() [2/2]

Integer STK::Law::NegativeBinomial::icdf ( Real const p,
int  size,
Real const prob 
)
static

inverse cumulative distribution function The quantile is defined as the smallest value x such that F(x) >= p , where F is the cumulative distribution function.

Parameters
pa probability number
prob,sizeprobability of success and number of successes in a NegativeBinomial trial

Definition at line 132 of file STK_Law_NegativeBinomial.cpp.

133{
134 return 0;
135}

◆ lpdf() [1/2]

Real STK::Law::NegativeBinomial::lpdf ( Integer const x) const
virtual

compute the log probability distribution function Give the value of the log-pdf at the point x.

Parameters
xa binary value
Returns
the value of the log-pdf

Reimplemented from STK::Law::IUnivLaw< Integer >.

Definition at line 66 of file STK_Law_NegativeBinomial.cpp.

67{
68 return 0;
69}

◆ lpdf() [2/2]

Real STK::Law::NegativeBinomial::lpdf ( Integer  x,
int  size,
Real const prob 
)
static

compute the log probability distribution function Give the value of the log-pdf at the point x.

Parameters
xan integer value
prob,sizeprobability of success and number of successes in a NegativeBinomial trial
Returns
the value of the log-pdf

Definition at line 113 of file STK_Law_NegativeBinomial.cpp.

114{
115 return 0;
116}

◆ pdf() [1/2]

Real STK::Law::NegativeBinomial::pdf ( Integer const x) const
virtual

compute the probability distribution function (density) Give the value of the pdf at the point x.

Parameters
xa binary value
Returns
the value of the pdf

Implements STK::Law::IUnivLaw< Integer >.

Definition at line 57 of file STK_Law_NegativeBinomial.cpp.

58{
59 return 0;
60}

◆ pdf() [2/2]

Real STK::Law::NegativeBinomial::pdf ( Integer  x,
int  size,
Real const prob 
)
static

compute the probability distribution function (density) Give the value of the pdf at the point x.

Parameters
xan integer value
prob,sizeprobability of success and number of successes in a NegativeBinomial trial
Returns
the value of the pdf

Definition at line 103 of file STK_Law_NegativeBinomial.cpp.

104{
105 return 0;
106}

◆ prob()

Real const & STK::Law::NegativeBinomial::prob ( ) const
inline
Returns
the probability of success

Definition at line 81 of file STK_Law_NegativeBinomial.h.

81{ return prob_;}

References prob_.

Referenced by setProb().

◆ rand() [1/2]

Integer STK::Law::NegativeBinomial::rand ( ) const
virtual
Returns
a Integer random variate .

Implements STK::Law::IUnivLaw< Integer >.

Definition at line 48 of file STK_Law_NegativeBinomial.cpp.

49{
50 return 0;
51}

◆ rand() [2/2]

Integer STK::Law::NegativeBinomial::rand ( int  size,
Real const prob 
)
static
Parameters
prob,sizeprobability of success and number of successes in a NegativeBinomial trial
Returns
a Integer random variate.

Definition at line 93 of file STK_Law_NegativeBinomial.cpp.

94{
95 return 0;
96}

◆ setProb()

void STK::Law::NegativeBinomial::setProb ( Real const prob)
inline
Parameters
probthe probability of success to set

Definition at line 85 of file STK_Law_NegativeBinomial.h.

86 {
89 prob_ = prob;
90 }
#define STKDOMAIN_ERROR_1ARG(Where, Arg, Error)
Definition STK_Macros.h:165

References prob(), prob_, setProb(), and STKDOMAIN_ERROR_1ARG.

Referenced by setProb().

◆ setSize()

void STK::Law::NegativeBinomial::setSize ( Integer  size)
inline
Parameters
sizethe number of successes to set

Definition at line 92 of file STK_Law_NegativeBinomial.h.

93 {
95 size_ = size;
96 }

References setSize(), size(), size_, and STKDOMAIN_ERROR_1ARG.

Referenced by setSize().

◆ size()

int STK::Law::NegativeBinomial::size ( ) const
inline
Returns
the number of trials

Definition at line 83 of file STK_Law_NegativeBinomial.h.

83{ return size_;}

References size_.

Referenced by setSize().

Member Data Documentation

◆ prob_

Real STK::Law::NegativeBinomial::prob_
protected

probability of success in a Bernoulli trial

Definition at line 172 of file STK_Law_NegativeBinomial.h.

Referenced by prob(), and setProb().

◆ size_

int STK::Law::NegativeBinomial::size_
protected

number of successes

Definition at line 170 of file STK_Law_NegativeBinomial.h.

Referenced by setSize(), and size().


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