Function for generating values from Bernoulli distributions.

Interface

bernoulli(p:real) : int

where 0.0<=p<=1.0. The value returned is either 0 or 1. The function returns a drawing from a Bernoulli distribution with probability p for success (i.e., success=1).

It raises Bernoulli exception if p<0.0 or p>1.0.

Characteristics

  • Mean: p
  • Variance: p(1-p)

Example

bernoulli(1.0/6.0)

Throw a die and observe if a six was thrown. This experiment has a Bernoulli distribution with parameter p=1/6 for success.

Related pages

Random distribution functions

Random distribution functions
Beta

You must be logged in to post a comment.