2024

Bernoulli distribution

The Bernoulli distribution is a discrete distribution with two possible outcomes, usually labelled \(S\) for “success” and \(F\) for “failure”, it applies equally well to any two dichotomous outcomes. It is a special case of the binomial distribution where a single trial is conducted (\(n=1\)).

The probability mass function is given by:

\[ f(x|p) = p^x (1-p)^{1-x} \]

where \(x \in \{0, 1\}\) and \(p\) is the probability of success.

Bernoulli distribution plots

Binomial distribution

The Binomial distribution is a discrete distribution with \(n\) independent trials, each with two possible outcomes, usually labelled \(S\) for “success” and \(F\) for “failure”. It is defined by two parameters: the number of trials \(n\) and the probability of success \(p\).

The probability mass function is given by:

\[ f(x|n, p) = \binom{n}{x} p^x (1-p)^{n-x} \]

where \(x \in \{0, 1, \ldots, n\}\) and \(p\) is the probability of success.

Binomial distribution plots

Getting probabilities from a Binomial

  • dbinom(x, size, prob) gives the probability mass function for the binomial distribution with parameters size and prob at the values x.

  • pbinom(x, size, prob) gives the cumulative distribution function for the binomial distribution with parameters size and prob at the values x.

  • qbinom(p, size, prob) gives the quantile function for probability p of the binomial distribution with parameters size and prob.

Binom(n=10, p=0.5): \(P(X>3)\)

  • 1 - pbinom(3, size=n, prob=p, lower.tail=TRUE)

  • 1 - sum(dbinom(0:3, size=n, prob=p))

Normal distribution

The normal distribution is a continuous distribution with a bell-shaped probability density function. It is defined by two parameters: the mean \(\mu\) and the standard deviation \(\sigma\).

The probability density function is given by:

\[ f(x|\mu, \sigma) = \frac{1}{\sqrt{2\pi\sigma^2}} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right) \]

where \(x \in \mathbb{R}\), \(\mu \in \mathbb{R}\) and \(\sigma > 0\).

Normal distribution plots

Getting probabilities from a Normal

  • dnorm(x, mean, sd) gives the probability density function for the normal distribution with parameters mean and sd at the values x.

  • pnorm(x, mean, sd) gives the cumulative distribution function for the normal distribution with parameters mean and sd at the values x.

  • qnorm(p, mean, sd) gives the quantile function for probability p of the normal distribution with parameters mean and sd.

Normal(\(\mu=0\), \(\sigma=1\)): \(P(X>1)\)

  • 1 - pnorm(1, mean=mu, sd=sigma, lower.tail=TRUE)