SciPy

Bernoulli DistributionΒΆ

A Bernoulli random variable of parameter \(p\) takes one of only two values \(X=0\) or \(X=1\) . The probability of success ( \(X=1\) ) is \(p\) , and the probability of failure ( \(X=0\) ) is \(1-p.\) It can be thought of as a binomial random variable with \(n=1\) . The PMF is \(p\left(k\right)=0\) for \(k\neq0,1\) and

\begin{eqnarray*} p\left(k;p\right) & = & \begin{cases} 1-p & k=0\\ p & k=1\end{cases}\\ F\left(x;p\right) & = & \begin{cases} 0 & x<0\\ 1-p & 0\le x<1\\ 1 & 1\leq x\end{cases}\\ G\left(q;p\right) & = & \begin{cases} 0 & 0\leq q<1-p\\ 1 & 1-p\leq q\leq1\end{cases}\\ \mu & = & p\\ \mu_{2} & = & p\left(1-p\right)\\ \gamma_{3} & = & \frac{1-2p}{\sqrt{p\left(1-p\right)}}\\ \gamma_{4} & = & \frac{1-6p\left(1-p\right)}{p\left(1-p\right)} \end{eqnarray*}
\[M\left(t\right) = 1-p\left(1-e^{t}\right)\]
\[\mu_{m}^{\prime}=p\]
\[h\left[X\right]=p\log p+\left(1-p\right)\log\left(1-p\right)\]

Implementation: scipy.stats.bernoulli