gammaParamsConvert: Gamma distribution shape and scale parameters from mean and...

Description Usage Arguments Value Author(s) Examples

View source: R/utils.R

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

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

Example output



ConnMatTools documentation built on Feb. 3, 2020, 5:06 p.m.