STK++ 0.9.13
|
Binomial probability law. More...
#include <STK_Law_Binomial.h>
Public Types | |
typedef IUnivLaw< Integer > | Base |
Public Member Functions | |
Binomial (int n=1, Real const &prob=0.5) | |
constructor | |
virtual | ~Binomial () |
destructor | |
int | n () const |
Real const & | prob () const |
void | setN (Integer n) |
void | setProb (Real const &prob) |
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 Binomial 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. | |
![]() | |
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. | |
![]() | |
String const & | name () const |
Static Public Member Functions | |
static Integer | rand (int n, Real const &prob) |
static Real | pdf (Integer x, int n, 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 n, 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 n, Real const &prob) |
compute the cumulative distribution function Give the probability that a Binomial random variate is less or equal to t. | |
static Integer | icdf (Real const &p, int n, 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 | n_ |
number of trials | |
Real | prob_ |
probability of success in a Bernoulli trial | |
![]() | |
String | name_ |
Name of the Law. | |
Additional Inherited Members | |
![]() | |
IUnivLaw (String const &name) | |
Constructor. | |
IUnivLaw (IUnivLaw const &law) | |
copy Constructor. | |
![]() | |
ILawBase (String const &name) | |
Constructor. | |
~ILawBase () | |
destructor. | |
Binomial probability law.
In probability theory and statistics, the Binomial distribution with parameters n and p is the discrete probability distribution of the number of successes in a sequence of n independent yes/no experiments, each of which yields success with probability p. A success/failure experiment is also called a Bernoulli experiment or Bernoulli trial. When n = 1, the binomial distribution is a Bernoulli distribution
In general, if the random variable X follows the binomial distribution with parameters n and p, we write
The binomial distribution is the basis for the popular binomial test of statistical significance.
Definition at line 64 of file STK_Law_Binomial.h.
Definition at line 67 of file STK_Law_Binomial.h.
constructor
prob | probability of success in a Binomial trial |
n | the number of trials |
Definition at line 72 of file STK_Law_Binomial.h.
References Binomial(), n(), prob(), and STKDOMAIN_ERROR_2ARG.
Referenced by Binomial().
|
inlinevirtual |
compute the cumulative distribution function Give the probability that a Binomial random variate is less or equal to t.
t | a real value |
Implements STK::Law::IUnivLaw< Integer >.
Definition at line 69 of file STK_Law_Binomial.cpp.
References STK::Arithmetic< Type >::NA().
compute the cumulative distribution function Give the probability that a Binomial random variate is less or equal to t.
t | a real value |
n,prob | number of trial and probability of success |
Definition at line 103 of file STK_Law_Binomial.cpp.
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.
p | a probability number |
Implements STK::Law::IUnivLaw< Integer >.
Definition at line 76 of file STK_Law_Binomial.cpp.
References STK::Arithmetic< Type >::NA().
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.
p | a probability number |
n,prob | number of trial and probability of success |
Definition at line 108 of file STK_Law_Binomial.cpp.
compute the log probability distribution function Give the value of the log-pdf at the point x.
x | a binary value |
Reimplemented from STK::Law::IUnivLaw< Integer >.
Definition at line 62 of file STK_Law_Binomial.cpp.
References STK::Funct::binomial_lpdf_raw(), n_, STK::Arithmetic< Type >::NA(), and prob_.
compute the log probability distribution function Give the value of the log-pdf at the point x.
x | a binary value |
n,prob | number of trial and probability of success |
Definition at line 96 of file STK_Law_Binomial.cpp.
References STK::Funct::binomial_lpdf_raw(), n(), STK::Arithmetic< Type >::NA(), and prob().
|
inline |
Definition at line 82 of file STK_Law_Binomial.h.
References n_.
Referenced by Binomial(), lpdf(), pdf(), and setN().
compute the probability distribution function (density) Give the value of the pdf at the point x.
x | a binary value |
Implements STK::Law::IUnivLaw< Integer >.
Definition at line 54 of file STK_Law_Binomial.cpp.
References STK::Funct::binomial_pdf_raw(), n_, STK::Arithmetic< Type >::NA(), and prob_.
compute the probability distribution function (density) Give the value of the pdf at the point x.
x | a binary value |
n,prob | number of trial and probability of success |
Definition at line 88 of file STK_Law_Binomial.cpp.
References STK::Funct::binomial_pdf_raw(), n(), STK::Arithmetic< Type >::NA(), and prob().
Definition at line 84 of file STK_Law_Binomial.h.
References prob_.
Referenced by Binomial(), lpdf(), pdf(), and setProb().
|
virtual |
Implements STK::Law::IUnivLaw< Integer >.
Definition at line 49 of file STK_Law_Binomial.cpp.
n,prob | number of trial and probability of success |
Definition at line 83 of file STK_Law_Binomial.cpp.
n | the number of trials to set |
Definition at line 86 of file STK_Law_Binomial.h.
References n(), n_, setN(), and STKDOMAIN_ERROR_1ARG.
Referenced by setN().
prob | the probability of success to set |
Definition at line 92 of file STK_Law_Binomial.h.
References prob(), prob_, setProb(), and STKDOMAIN_ERROR_1ARG.
Referenced by setProb().
|
protected |
|
protected |