Overview

TypeDistributionR SuffixComments
ContinuousNormal-norm()
Lognormal-lnorm()Normally distributed in a log scale
Uniform-unif()
DiscreteBinomial-binom()
Multinomial-multinom()Similar to binomial but when there are more than 2 outcomes
Poisson-pois()

Prefix:

Normal Distribution

  • dnorm(x, mean = 0, sd = 1): PDF
  • pnorm(x, mean = 0, sd = 1, lower.tail = TRUE) CDF
  • qnorm(x, mean = 0, sd = 1, lower.tail = TRUE): quantile function
  • rnorm(x, mean = 0, sd = 1): generates random deviates

Explanation

pnorm is the CDF, which is the area under the normal curve below certain threshold. If we set lower.tail = FALSE, we are essentially compute the area above q (a.k.a. 1 - pnorm(x, mean, sd)) pnorm.png

qnorm(p, mean = 0, sd = 1, lower.tail = TRUE) calculates the value such that the area of the curve below this value is equal to p. qnorm.png

For example, given a random variable , , pnorm finds , given and qnorm finds given .

Binomial Distribution

See: Binomial

  • x: number of events
  • n: number of trails
  • p or prob: probability of success

The R function family provided by the binomial distribution shares the similar postfixes as the normal distribution.

  • dbinom(x, n, p): PMF
  • pbinom(x, n, p, lower.tail = TRUE): CDF
  • qninom(x, n, p, lower.tail = TRUE): quantile function
  • rbinom(x, n, p): generates random deviates

Examples

Compute for

sum(dbinom(46:54, 100, 0.5))

Alternatively

pbinom(54, 100, 0.5) - pbinom(45, 100, 0.5)