13.1 Bernoulli distribution
13.1.1 Probability mass function
If \(\theta \in [0,1]\), then for \(y \in \{0,1\}\), \[ \text{Bernoulli}(y~|~\theta) = \left\{ \begin{array}{ll} \theta & \text{if } y = 1, \text{ and} \\ 1 - \theta & \text{if } y = 0. \end{array} \right. \]
13.1.2 Sampling statement
y ~
bernoulli
(theta)
Increment target log probability density with bernoulli_lupmf(y | theta)
.
Available since 2.0
13.1.3 Stan Functions
real
bernoulli_lpmf
(ints y | reals theta)
The log Bernoulli probability mass of y given chance of success theta
Available since 2.12
real
bernoulli_lupmf
(ints y | reals theta)
The log Bernoulli probability mass of y given chance of success theta
dropping constant additive terms
Available since 2.25
real
bernoulli_cdf
(ints y, reals theta)
The Bernoulli cumulative distribution function of y given chance of
success theta
Available since 2.0
real
bernoulli_lcdf
(ints y | reals theta)
The log of the Bernoulli cumulative distribution function of y given
chance of success theta
Available since 2.12
real
bernoulli_lccdf
(ints y | reals theta)
The log of the Bernoulli complementary cumulative distribution
function of y given chance of success theta
Available since 2.12
R
bernoulli_rng
(reals theta)
Generate a Bernoulli variate with chance of success theta
; may only be
used in transformed data and generated quantities blocks.
For a description of argument and return types, see section
vectorized PRNG functions.
Available since 2.18