Leslie Hendrix
August, 2020
Calculations under Distributions
The ‘d’ functions in R calculate the the PMF or PDF values for a distribution.
- f(x) = P(X = x) for discrete distributions, but NOT a probability for continuous distributions
The ‘p’ functions in R calculate the CDF
- F(x) = P(X <= x)
The ‘q’ functions in R calcuate a percentile, that is they take the area to the left, and return a value in the distribution.
Binomial
dbinom(j,n,p) gives P(Y = j) and pbinom(J,n,p) gives P(<=J) = P(Y = 0) + P(Y = 1) + … + P(Y = J)
Poisson
dpois(j,lambda) gives P(Y=j) and
ppois(J,lambda) gives P(Y<=J)
Continuous Uniform
punif(x,a,b) gives P(X<=x) in the uniform distribution with lower limit, a, and upper limit b
qunif(p,a,b) gives the pth percentile
Exponential
pexp(x,lambda) gives P(Y<=j)
qexp(p, lambda) gives the pth percentile
Normal
pnorm(x,mu,sigma) gives Pr{X < x} for X~N(mu,sigma) …..so, 1-pnorm(x,mu,sigma) gives Pr(X > x)
qnorm(p,mu,sigma) gives the value in the normal distribution (with mean mu and sd sigma) that has p to the left of it
t distribution
pt(t,df) gives Pr{T < t} for T~t(df)
qt(p,df) gives the value of the t distribution with df=df that has p to the left of it
Tips
- Note that the ‘d’ functions calculate the height of the curve at that X value for a continuous distribution. This is NOT a probability.
- The ‘q’ and ‘p’ functions do the opposite calculation.
- The ‘p’ functions take a value in a distribution and return the area to the left.
- The ‘q’ functions take the area to the left and return a value in the distribution.