Skip to content

BernoulliDistribution ​

The Bernoulli distribution: 11 with probability pp, 00 with probability 1−p1-p.

BernoulliDistribution(p)an inert distribution object — carries pp, unevaluated.
Typed signatures
TypePackageApplies
(real<0..1>) -> distributionstatisticsalways

Domain: Statistics

Details
  • PDFPDF is 1−p1-p at 00, pp at 11, and 00 elsewhere.
  • CDFCDF is 00 below 00, 1−p1-p on [0,1)[0,1), and 11 from 11 on.
  • Mean=pMean = p, Variance=p(1−p)Variance = p(1-p), both exact.
  • RandomVariate draws a single uniform and compares it to pp.

Examples

Basic #
live ↗
InPDF⁡(BernoulliDistribution(13),1)\operatorname{PDF}(\mathrm{BernoulliDistribution}(\frac{1}{3}), 1)Out13\frac{1}{3}
live ↗
InCDF⁡(BernoulliDistribution(13),0)\operatorname{CDF}(\mathrm{BernoulliDistribution}(\frac{1}{3}), 0)Out23\frac{2}{3}
live ↗
Inmean(BernoulliDistribution(13))\mathrm{mean}(\mathrm{BernoulliDistribution}(\frac{1}{3}))Out13\frac{1}{3}
live ↗
InVariance(BernoulliDistribution(13))\mathrm{Variance}(\mathrm{BernoulliDistribution}(\frac{1}{3}))Out29\frac{2}{9}
About
Examples4

See also: GeometricDistribution, BinomialDistribution, PDF, CDF