Skip to contents

Create a ddf object for the Bernoulli distribution with the given parameters.

Usage

bernoulli(p)

Arguments

p

A number between 0 and 1, the success probability.

Value

A ddf distribution as described above.

Details

The Bernoulli distribution with success probability \(p\) only has the two elements \(0\) and \(1\) as its support with the corresponding probability mass function being given by $$p(k) = \begin{cases} p & \text{if } k = 1,\\ 1-p & \text{if } k = 0. \end{cases}$$ Hence, it can be used to model experiments asking a single yes-no question or experiments whose only outcomes are "success" and "failure".

See also

Examples

# Distribution modelling a fair coin toss
bernoulli(1 / 2)
#> Bernoulli distribution with p = 0.5 
#> 
#> Support:
#> [1] 0 1
#> 
#> Probabilities:
#> [1] 0.5 0.5