gammaParamsConvert {ConnMatTools}R Documentation

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

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

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

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")

[Package ConnMatTools version 0.3.5 Index]