10.2 Other Distributions

In Section 10.1, we discussed the normal distribution, a popular continuous distribution, along with its key functions. Here, we explore discrete distributions and other common distributions in probability and statistics.

10.2.1 Discrete vs. Continuous Distributions

  • Continuous Distributions: Use the probability density function (PDF) to describe probabilities over intervals (e.g., the normal distribution).
  • Discrete Distributions: Use the probability mass function (PMF) to describe probabilities at specific points (e.g., the binomial distribution, the Poisson distribution).

10.2.2 Binomial Distribution

The binomial distribution models the number of successes in a fixed number of independent trials, each with the same probability of success. If \(X \sim \text{Binomial}(n, p)\):

  • \(n\) is the number of trials.
  • \(p\) is the probability of success on each trial.

we have the following key functions for the Binomial Distribution

Code Description
dbinom(x, size, prob) pmf: Gives the probability of exactly x successes.
pbinom(q, size, prob) cdf: Gives the probability of <= q successes.
qbinom(p, size, prob) quantile: Finds the smallest value x where the cdf is >= p.
rbinom(n, size, prob) Generates random samples from the distribution.

Let’s look at an example of \(\text{Binomial}(10, 0.5)\).

size <- 10  # Number of trials
prob <- 0.5  # Probability of success

# pmf: Probability of exactly 5 successes
dbinom(5, size, prob)
#> [1] 0.2460938

# cdf: Probability of 5 or fewer successes
pbinom(5, size, prob)
#> [1] 0.6230469

10.2.3 Poisson Distribution

The Poisson distribution models the number of events occurring in a fixed interval of time or space, assuming the events occur independently. If \(X \sim \text{Poisson}(\lambda)\), where \(\lambda\) is the average rate of occurrence, then we have the following functions.

Code Description
dpois(x, lambda) pmf: Gives the probability of exactly x events.
ppois(q, lambda) cdf: Gives the probability of <= q events.
qpois(p, lambda) quantile: Finds the smallest value x where the cdf is >= p.
rpois(n, lambda) Generates random samples from the distribution.

Let’s look at \(\text{Poisson}(4)\).

lambda <- 4  # Average rate of occurrence

# PMF: Probability of exactly 3 events
dpois(3, lambda)
#> [1] 0.1953668

10.2.4 Exponential Distribution

The exponential distribution models the time between events in a Poisson process. If \(X \sim \text{Exponential}(\lambda)\), where \(\lambda\) is the rate parameter, we have the following functions.

Function Description
dexp(x, rate) pdf: Gives the density at a specific value.
pexp(q, rate) cdf: Gives the probability of <= q.
qexp(p, rate) quantile: Finds the smallest value x where the cdf is >= p.
rexp(n, rate) Generates random samples from the distribution.

Let’s look at an example of \(\text{Exponential}(2)\).

rate <- 2  # Rate parameter

# PDF: Density at x = 1
dexp(1, rate)
#> [1] 0.2706706

10.2.5 A Summary of Commonly Used Distributions

Now, let’s look at a summary of commonly used distributions. For simplicity, let’s just use the random number generator for each distribution in the following table.

Name Code para_1 para_2
exponential rexp(3, rate = 0.5) rate
uniform runif(3, min = 1, max = 2) min max
t rt(3, df = 4) df
F rf(3, df1 = 3, df2 = 6) df1 df2
beta rbeta(3, shape1 = 2, shape2 = 3) shape1 shape2
gamma rgamma(3, shape = 2, rate = 3) shape rate
poisson rpois(3, lambda = 5) lambda
binomial rbinom(3, size = 3, prob = 0.3) size prob
bernoulli rbinom(3, size = 1, prob = 0.5) size prob

As we can see from this table, all random number generator functions are formed by the letter r followed by the name of the distribution we would like to generate from. For the other three functions, we just need to change the initial letter r:

  • to d for pdf (continuous distribution) or pmf (discrete distribution),
  • to p for cdf,
  • to q for quantile function.

Let’s do some statistical exercises with those distributions.

10.2.6 Exercise

  1. For \(\text{Binomial}(10, 0.5)\),
  • (a). Compute the pmf for x = 0, 1, ..., 10. Plot the pmf.
  • (b). Calculate the cdf and interpret the results.
  • (c). Simulate 1000 random values using rbinom() and compare the histogram with the theoretical pmf.
  1. For \(\text{Poisson}(3)\),
  • (a). Compute the pmf for x = 0, 1, ..., 10. Plot the pmf.
  • (b). Use ppois() to calculate the probability of 2 or fewer events.
  • (c). Generate 500 random values using rpois() and create a histogram. Compare it with the theoretical pmf.
  1. For \(\text{Exponential}\) distribution with rate = 0.5,
  • (a). Compute the pdf for x = 0.5, 1, 1.5, ..., 5 with rate = 0.5. Plot the pdf.
  • (b). Simulate 1000 random samples using rexp() with rate = 0.5. Create a histogram and compare it with the theoretical pdf.