9.2 Other Distributions

In Section 9.1, we gave a detailed introduction to the four functions for a normal distribution, which is a popular continuous distribution. In particular, we now know that dnorm() produces the pdf of a normal distribution. In the case of discrete distributions, however, we would have probability mass function (pmf) instead of the pdf. Let’s use the binomial distribution as a representative example of discrete distributions with the four functions as below.

Code Name
dbinom(3, size, prob) probability mass function
pbinom(3, size, prob) cumulative distribution function
qbinom(3, size, prob) quantile function
rbinom(3, size, prob) random number generator

Now, let’s look at a few other 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.

9.2.1 Exercise