STK++ 0.9.13
STK::Law::HyperGeometric Class Reference

HyperGeometric probability law. More...

#include <STK_Law_HyperGeometric.h>

Inheritance diagram for STK::Law::HyperGeometric:
Inheritance graph

Public Types

typedef IUnivLaw< IntegerBase
 

Public Member Functions

 HyperGeometric (int nbSuccesses, int nbFailures, int nbDraws)
 constructor
 
virtual ~HyperGeometric ()
 destructor
 
int nbSuccesses () const
 
int nbFailures () const
 
int nbDraws () const
 
void setNbSuccesses (int nbSuccesses)
 
void setNbFailures (int nbFailures)
 
void setNbDraws (int nbDraws)
 
virtual Integer rand () const
 
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 Real cdf (Real const &t) const
 compute the cumulative distribution function Give the probability that a HyperGeometric random variate is less or equal to t.
 
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 nbSuccesses, int nbFailures, int nbDraws)
 random hypergeometric variate generation.
 
static Real pdf (Integer x, int nbSuccesses, int nbFailures, int nbDraws)
 compute the probability distribution function.
 
static Real lpdf (Integer x, int nbSuccesses, int nbFailures, int nbDraws)
 compute the log probability distribution function.
 
static Real cdf (Real const &t, int nbSuccesses, int nbFailures, int nbDraws)
 compute the cumulative distribution function Give the probability that a HyperGeometric random variate is less or equal to t.
 
static Integer icdf (Real const &p, int nbSuccesses, int nbFailures, int nbDraws)
 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 nbSuccesses_
 number of successes
 
int nbFailures_
 number of failures
 
int nbDraws_
 number of draws
 
- 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

HyperGeometric probability law.

In probability theory and statistics, the hypergeometric distribution is a discrete probability distribution that describes the probability of x successes in k draws, without replacement, from a finite population of size m+n that contains exactly m successes, wherein each draw is either a success or a failure. In contrast, the binomial distribution describes the probability of k successes inn draws with replacement.

The hypergeometric distribution is used for sampling without replacement. The density of this distribution with parameters m, n and k is given by

\[
   p(x;m,n,k) = \frac{\binom{m}{x} \binom{n}{k-x}}{\binom{m+n}{k}}
   \quad x=0,\ldots,k, \quad m\geq 0,\quad n\geq 0,\quad 0\leq k \leq m+n.
\]

Definition at line 64 of file STK_Law_HyperGeometric.h.

Member Typedef Documentation

◆ Base

Constructor & Destructor Documentation

◆ HyperGeometric()

STK::Law::HyperGeometric::HyperGeometric ( int  nbSuccesses,
int  nbFailures,
int  nbDraws 
)
inline

constructor

Parameters
nbSuccesses,nbFailures,nbDrawsnumber of successes, failures, draws

Definition at line 71 of file STK_Law_HyperGeometric.h.

72 : Base(_T("HyperGeometric"))
76 {}
#define _T(x)
Let x unmodified.
int nbSuccesses_
number of successes
int nbFailures_
number of failures

◆ ~HyperGeometric()

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

destructor

Definition at line 78 of file STK_Law_HyperGeometric.h.

78{}

Member Function Documentation

◆ cdf() [1/2]

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

compute the cumulative distribution function Give the probability that a HyperGeometric 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 77 of file STK_Law_HyperGeometric.cpp.

78{
79 return 0;
80}

◆ cdf() [2/2]

Real STK::Law::HyperGeometric::cdf ( Real const t,
int  nbSuccesses,
int  nbFailures,
int  nbDraws 
)
static

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

Parameters
ta real value
nbSuccesses,nbFailures,nbDrawsnumber of successes, failures, draws
Returns
the value of the cdf

Definition at line 124 of file STK_Law_HyperGeometric.cpp.

125{
126 return 0;
127}

◆ icdf() [1/2]

Integer STK::Law::HyperGeometric::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 86 of file STK_Law_HyperGeometric.cpp.

87{
88 return 0;
89}

◆ icdf() [2/2]

Integer STK::Law::HyperGeometric::icdf ( Real const p,
int  nbSuccesses,
int  nbFailures,
int  nbDraws 
)
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
nbSuccesses,nbFailures,nbDrawsnumber of successes, failures, draws

Definition at line 133 of file STK_Law_HyperGeometric.cpp.

134{
135 return 0;
136}

◆ lpdf() [1/2]

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

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

Parameters
xan Integer value
Returns
the value of the log-pdf

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

Definition at line 67 of file STK_Law_HyperGeometric.cpp.

68{
69 return 0;
70}

◆ lpdf() [2/2]

Real STK::Law::HyperGeometric::lpdf ( Integer  x,
int  nbSuccesses,
int  nbFailures,
int  nbDraws 
)
static

compute the log probability distribution function.

Parameters
xan Integer value
nbSuccesses,nbFailures,nbDrawsnumber of successes, failures, draws
Returns
the value of the log-pdf

Definition at line 114 of file STK_Law_HyperGeometric.cpp.

115{
116 return 0;
117}

◆ nbDraws()

int STK::Law::HyperGeometric::nbDraws ( ) const
inline
Returns
the number of draws

Definition at line 84 of file STK_Law_HyperGeometric.h.

84{ return nbDraws_;}

References nbDraws_.

Referenced by setNbDraws().

◆ nbFailures()

int STK::Law::HyperGeometric::nbFailures ( ) const
inline
Returns
the number of failures

Definition at line 82 of file STK_Law_HyperGeometric.h.

82{ return nbFailures_;}

References nbFailures_.

Referenced by setNbDraws(), and setNbFailures().

◆ nbSuccesses()

int STK::Law::HyperGeometric::nbSuccesses ( ) const
inline
Returns
the number of successes

Definition at line 80 of file STK_Law_HyperGeometric.h.

80{ return nbSuccesses_;}

References nbSuccesses_.

Referenced by setNbDraws(), and setNbSuccesses().

◆ pdf() [1/2]

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

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

Parameters
xan Integer value
Returns
the value of the pdf

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

Definition at line 58 of file STK_Law_HyperGeometric.cpp.

59{
60 return 0;
61}

◆ pdf() [2/2]

Real STK::Law::HyperGeometric::pdf ( Integer  x,
int  nbSuccesses,
int  nbFailures,
int  nbDraws 
)
static

compute the probability distribution function.

Give the value of the pdf at the point x.

Parameters
xan Integer value
nbSuccesses,nbFailures,nbDrawsnumber of successes, failures, draws
Returns
the value of the pdf

Definition at line 105 of file STK_Law_HyperGeometric.cpp.

106{
107 return 0;
108}

◆ rand() [1/2]

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

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

Definition at line 49 of file STK_Law_HyperGeometric.cpp.

50{
51 return 0;
52}

◆ rand() [2/2]

Integer STK::Law::HyperGeometric::rand ( int  nbSuccesses,
int  nbFailures,
int  nbDraws 
)
static

random hypergeometric variate generation.

Parameters
nbSuccesses,nbFailures,nbDrawsnumber of successes, failures, draws
Returns
a Integer random variate.

Definition at line 95 of file STK_Law_HyperGeometric.cpp.

96{
97 return 0;
98}

◆ setNbDraws()

void STK::Law::HyperGeometric::setNbDraws ( int  nbDraws)
inline
Parameters
nbDrawsthe number of draws to set

Definition at line 100 of file STK_Law_HyperGeometric.h.

101 {
102 if (nbDraws<0)
107 }
#define STKDOMAIN_ERROR_1ARG(Where, Arg, Error)
Definition STK_Macros.h:165

References nbDraws(), nbDraws_, nbFailures(), nbFailures_, nbSuccesses(), nbSuccesses_, setNbDraws(), and STKDOMAIN_ERROR_1ARG.

Referenced by setNbDraws().

◆ setNbFailures()

void STK::Law::HyperGeometric::setNbFailures ( int  nbFailures)
inline
Parameters
nbFailuresthe number of failures to set

Definition at line 93 of file STK_Law_HyperGeometric.h.

References nbFailures(), nbFailures_, setNbFailures(), and STKDOMAIN_ERROR_1ARG.

Referenced by setNbFailures().

◆ setNbSuccesses()

void STK::Law::HyperGeometric::setNbSuccesses ( int  nbSuccesses)
inline
Parameters
nbSuccessesthe number of successes to set

Definition at line 86 of file STK_Law_HyperGeometric.h.

References nbSuccesses(), nbSuccesses_, setNbSuccesses(), and STKDOMAIN_ERROR_1ARG.

Referenced by setNbSuccesses().

Member Data Documentation

◆ nbDraws_

int STK::Law::HyperGeometric::nbDraws_
protected

number of draws

Definition at line 185 of file STK_Law_HyperGeometric.h.

Referenced by nbDraws(), and setNbDraws().

◆ nbFailures_

int STK::Law::HyperGeometric::nbFailures_
protected

number of failures

Definition at line 183 of file STK_Law_HyperGeometric.h.

Referenced by nbFailures(), setNbDraws(), and setNbFailures().

◆ nbSuccesses_

int STK::Law::HyperGeometric::nbSuccesses_
protected

number of successes

Definition at line 181 of file STK_Law_HyperGeometric.h.

Referenced by nbSuccesses(), setNbDraws(), and setNbSuccesses().


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