knitr::opts_chunk$set(prompt=FALSE, comment="")

Distribution Functions

You may skip this section on a first read through, and come back to it later when you need these.

R has a family of functions for each probability distribution. The distributions we'll likely use in this course are:

Note that each of these distributions has four R functions. For example, for the Poisson distribution (which has one parameter, lambda) these are:

  1. dpois(x, lambda): the probability density.
  2. ppois(x, lambda): the probability distribution, e.g. the density integrated (or summed) from -Infinity to x, giving the probability of values less extreme than x.
  3. qpois(p, lambda): the quantile function, which returns the quantile for a supplied probability p.
  4. rpois(n, lambda): return n random samples from a Poisson distribution.

When sampling random variables, it's sometimes useful to set the random seed. Random numbers are sampled from a pseudo random number generator; the pseudo means these aren't truly random as setting the seed ensures the same sequence of random numbers can be generated. For example:

set.seed(3)
rnorm(10)
set.seed(3)
rnorm(10)
set.seed(4)  # set seed for different sequence of numbers
rnorm(10)

Note the same sequence is returned once we set the seed to the same seed.



vsbuffalo/eve102 documentation built on May 3, 2019, 7:07 p.m.