|
STK++ 0.9.13
|
Bernoulli probability law. More...
#include <STK_Law_Bernoulli.h>

Public Types | |
| typedef IUnivLaw< Binary > | Base |
Public Member Functions | |
| Bernoulli (Real const &prob=0.5) | |
| constructor | |
| virtual | ~Bernoulli () |
| destructor | |
| Real const & | prob () const |
| void | setProb (Real const &prob) |
| virtual Binary | rand () const |
| virtual Real | pdf (Binary const &x) const |
| compute the probability distribution function (density) Give the value of the pdf at the point x. | |
| virtual Real | lpdf (Binary 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 Bernoulli random variate is less or equal to t. | |
| virtual Binary | icdf (Real const &prob) 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< Binary > | |
| 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 const & | name () const |
Static Public Member Functions | |
| static Binary | rand (Real const &prob) |
| static Real | pdf (Binary const &x, Real const &prob) |
| compute the probability distribution function (density) Give the value of the pdf at the point x. | |
| static Real | lpdf (Binary const &x, Real const &prob) |
| compute the log probability distribution function Give the value of the log-pdf at the point x. | |
Protected Attributes | |
| 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< Binary > | |
| 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. | |
Bernoulli probability law.
In probability theory and statistics, the Bernoulli distribution, named after Swiss scientist Jacob Bernoulli, is a discrete probability distribution, which takes value 1 with success probability p and value 0 with failure probability q=1-p. So if X is a random variable with this distribution, we have:
![\[
\mathbb{P}(X=1) = 1 - \mathbb{P}(X=0) = 1 - q = p.
\]](form_214.png)
A classical example of a Bernoulli experiment is a single toss of a coin. The coin might come up heads with probability p and tails with probability 1-p. The experiment is called fair if p=0.5, indicating the origin of the terminology in betting (the bet is fair if both possible outcomes have the same probability).
Definition at line 63 of file STK_Law_Bernoulli.h.
Definition at line 66 of file STK_Law_Bernoulli.h.
constructor
| prob | probability of success in a Bernoulli trial |
Definition at line 70 of file STK_Law_Bernoulli.h.
References prob(), and STKDOMAIN_ERROR_1ARG.
|
inlinevirtual |
compute the cumulative distribution function Give the probability that a Bernoulli random variate is less or equal to t.
| t | a real value |
Implements STK::Law::IUnivLaw< Binary >.
Definition at line 162 of file STK_Law_Bernoulli.h.
References 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.
| prob | a probability number |
Implements STK::Law::IUnivLaw< Binary >.
Definition at line 164 of file STK_Law_Bernoulli.h.
References icdf(), STK::one_, prob(), prob_, STKDOMAIN_ERROR_1ARG, and STK::zero_.
Referenced by icdf().
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< Binary >.
Definition at line 152 of file STK_Law_Bernoulli.h.
References STK::Arithmetic< Type >::NA(), STK::one_, prob_, and STK::zero_.
Referenced by lpdf().
compute the log probability distribution function Give the value of the log-pdf at the point x.
| x | a binary value |
| prob | a probability number |
Definition at line 197 of file STK_Law_Bernoulli.h.
References lpdf(), STK::Arithmetic< Type >::NA(), STK::one_, prob(), STKDOMAIN_ERROR_1ARG, and STK::zero_.
compute the probability distribution function (density) Give the value of the pdf at the point x.
| x | a binary value |
Implements STK::Law::IUnivLaw< Binary >.
Definition at line 142 of file STK_Law_Bernoulli.h.
References STK::Arithmetic< Type >::NA(), STK::one_, prob_, and STK::zero_.
Referenced by pdf().
compute the probability distribution function (density) Give the value of the pdf at the point x.
| x | a binary value |
| prob | a probability number |
Definition at line 183 of file STK_Law_Bernoulli.h.
References STK::Arithmetic< Type >::NA(), STK::one_, pdf(), prob(), STKDOMAIN_ERROR_1ARG, and STK::zero_.
Definition at line 78 of file STK_Law_Bernoulli.h.
References prob_.
Referenced by Bernoulli(), icdf(), lpdf(), pdf(), rand(), and setProb().
|
inlinevirtual |
Implements STK::Law::IUnivLaw< Binary >.
Definition at line 139 of file STK_Law_Bernoulli.h.
References STK::one_, prob_, and STK::zero_.
Referenced by rand().
| prob | a probability number |
Definition at line 174 of file STK_Law_Bernoulli.h.
References STK::one_, prob(), rand(), STKDOMAIN_ERROR_1ARG, and STK::zero_.
| prob | the probability of success to set |
Definition at line 80 of file STK_Law_Bernoulli.h.
References prob(), prob_, setProb(), and STKDOMAIN_ERROR_1ARG.
Referenced by STK::BernoulliModel< Array, WColVector >::computeParameters(), STK::BernoulliModel< Array, WColVector >::computeParameters(), and setProb().
|
protected |