Gamma distribution shape and scale parameters from mean and standard deviation, or vice-versa

Share:

Description

Calculates shape and scale parameters for a gamma distribution from the mean and standard deviation of the distribution, or vice-versa. One supplies either mean and sd or shape and scale and the function returns a list with all four parameter values.

Usage

1
gammaParamsConvert(...)

Arguments

...

This function can be run either supplying mean and sd, or supplying shape and scale, but not both pairs of parameters.

Value

A list with mean, sd, shape and scale parameters of the corresponding gamma distribution.

Author(s)

David M. Kaplan dmkaplan2000@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(ConnMatTools)
mn <- 1
sd <- 0.4
l <- gammaParamsConvert(mean=mn,sd=sd)
x <- seq(0,2,length.out=50)

# Plot gamma and normal distributions - for sd << mean, the two should be very close
plot(x,dgamma(x,l$shape,scale=l$scale),
     main="Normal versus Gamma distributions",type="l")
lines(x,dnorm(x,l$mean,l$sd),col="red")

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.