B Using R with distributions

In R, standard distributions have four associated functions:

For example, the fours function above are called, for the normal distribution (denoted norm in R):

B.1 Univariate distributions

Common parameters:

  • x: Values where to evaluate the probability function
  • q: Quantiles
  • p: Probabilities
  • n: The number of random observations to generate

Most distributions have other parameters also; check the help (e.g., ?punif).

Distribution Probability function Distribution function Quantile function Random numbers
Discrete uniform sample()
Binomial dbinom() pbinom() qbinom() rbinom(n, )
Poisson dpois() ppois() qpois() rpois(n, )
Geometric dgeom() pgeom() qgeom() rgeom(n, )
Negative binomial dnbinom() pnbinom() qnbinom() rnbinom(n, )
Continuous uniform dunif() punif() qunif() runif(n, )
Normal dunif() punif() qunif() runif(n, )
Gamma dgamma() pgammma() qgamma() rgamma(n, )
\(t\) dt() pt() qt() rt(n, )
\(\chi\)-squared dchisq() pchisq() qchisq() rchisq(n, )
\(F\) df() pf() qf() rf(n, )

B.2 Multivariate distributions

The multinomial distribution:

The multivariate normal distribution: