# Probability distributions # take normal as first example # there are 4 functions # rnorm - draw a random normal number # pnorm - distribution function F(x) # qnorm - quantile function F^-1(p) # dnorm - density function f(x) # see ?Normal # let X be normal(0, 1) # what's the probability X < 3 pnorm(3) # what's the probability X > 3 1 - pnorm(3) # or pnorm(3, lower.tail = FALSE) # what number is the 0.9 quantile (i.e. what z has P(X < z) = 0.9) qnorm(0.9) # what's a normal density look like x <- seq(-4, 4, 0.01) plot(x, dnorm(x), type = 'l') # I need 10 random standard normals (i.e x_1, ..., x_10 iid N(0, 1)) rnorm(10) # All take mean and sd arguments pnorm(3, mean = 2, sd = 1) # All other distributions follow the same format # for example: Poisson # rpois # ppois # qpois # dpois # take lambda argument (called theta in the book) # other dists: try ?Chisquare ?Binomial ?Uniform ?GammaDist # Q: What's the probability of a Normal random variable with mean 5 and variance # 4 being greater than 2? # Q: What's the probability of a Poisson random variable with mean 10 being # between 7 and 11? # Q: Plot the density of a Gamma with scale 4 and shape 1. Overlay a histogram of 50 random draws from the same distribution.