These functions provide the density, distribution function, quantile function, and random generation for the Bernoulli distribution.
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)
These are each a vector of quantiles.
This is a vector of probabilities.
This is the number of observations. If length(n) > 1
,
then the length is taken to be the number required.
This is the probability of success on each trial.
Logical. if TRUE
, probabilities \(p\) are
given as \(\log(p)\).
Logical. if TRUE
(default), probabilities
are \(Pr[X \le x]\), otherwise,
\(Pr[X > x]\).
dbern
gives the density,
pbern
gives the distribution function,
qbern
gives the quantile function, and
rbern
generates random deviates.
Application: Continuous Univariate
Density: \(p(\theta) = {p}^{\theta} {(1-p)}^{1-\theta}\), \(\theta = 0,1\)
Inventor: Jacob Bernoulli
Notation 1: \(\theta \sim \mathcal{BERN}(p)\)
Notation 2: \(p(\theta) = \mathcal{BERN}(\theta | p)\)
Parameter 1: probability parameter \(0 \le p \le 1\)
Mean: \(E(\theta) = p\)
Variance: \(var(\theta) = \frac{p}{1-p}\)
Mode: \(mode(\theta) =\)
The Bernoulli distribution is a binomial distribution with \(n=1\), and one instance of a Bernoulli distribution is called a Bernoulli trial. One coin flip is a Bernoulli trial, for example. The categorical distribution is the generalization of the Bernoulli distribution for variables with more than two discrete values. The beta distribution is the conjugate prior distribution of the Bernoulli distribution. The geometric distribution is the number of Bernoulli trials needed to get one success.
# NOT RUN {
library(LaplacesDemon)
dbern(1, 0.7)
rbern(10, 0.5)
# }
Run the code above in your browser using DataLab