Bernoulli | R Documentation |
Density, distribution function, quantile function and random
generation for the Bernoulli distribution with parameter prob
.
dbern(x, prob, log = FALSE) pbern(q, prob, lower.tail = TRUE, log.p = FALSE) qbern(p, prob, lower.tail = TRUE, log.p = FALSE) rbern(n, prob)
x, q |
vector of quantiles. |
p |
vector of probabilities. |
n |
number of observations. If |
prob |
probability of success on 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]. |
The Bernoulli distribution with prob
= p has density
p(x) = p^x (1-p)^(1-x)
for x = 0 or 1.
If an element of x
is not 0
or 1
, the result of dbern
is zero, without a warning.
p(x) is computed using Loader's algorithm, see the reference below.
The quantile is defined as the smallest value x such that F(x) ≥ p, where F is the distribution function.
dbern
gives the density, pbern
gives the distribution
function, qbern
gives the quantile function and rbern
generates random deviates.
Catherine Loader (2000). Fast and Accurate Computation of Binomial Probabilities; manuscript available from http://cm.bell-labs.com/cm/ms/departments/sia/catherine/dbinom
dbinom
for the binomial (Bernoulli is a special case
of the binomial), and dpois
for the Poisson distribution.
# Compute P(X=1) for X Bernoulli(0.7) dbern(1, 0.7)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.