Calculations under Distributions

The ‘d’ functions in R calculate the the PMF or PDF values for a distribution.

The ‘p’ functions in R calculate the CDF

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

<Previous | Next>