bernoulli: The Bernoulli Distribution

bernoulliR Documentation

The Bernoulli Distribution

Description

Density, distribution function, quantile function and random generation for the Bernoulli distribution with probability equals to ‘⁠prob⁠’.

Usage

dbern(x, prob = 0.5, log = FALSE)

pbern(q, prob = 0.5, lower.tail = TRUE, log.p = FALSE)

qbern(p, prob = 0.5, lower.tail = TRUE, log.p = FALSE)

rbern(n, prob = 0.5)

Arguments

x, q

vector of quantiles.

prob

vector of probabilities of success of each trial.

log, log.p

logical; if ‘⁠TRUE⁠’, probabilities ‘⁠p⁠’ are given as ‘⁠log(p)⁠’.

lower.tail

logical; if ‘⁠TRUE⁠’ (default), probabilities are ‘⁠P[X <= x]⁠’, otherwise, ‘⁠P[X > x]⁠’.

p

vector of probabilities.

n

number of observations. If ‘⁠length(n) > 1⁠’, the length is taken to be the number required.

Details

These functions use the corresponding functions from the binomial distribution with argument ‘⁠size = 1⁠’. Thus, 1 is for success, 0 is for failure.

Value

‘⁠dbern⁠’ gives the density, ‘⁠pbern⁠’ gives the distribution function, ‘⁠qbern⁠’ gives the quantile function, and ‘⁠rbern⁠’ generates random deviates.

See Also

Binomial

Examples

rbern(n = 10, prob = .5)
rbern(n = 3, prob = c(0, .5, 1))

mc2d documentation built on Oct. 23, 2026, 1:06 a.m.