Mean and standard deviation parameterised gamma sampling function

rgamma_with_mean_sd(n, mean, sd)

Arguments

n

Numeric, the number of samples to take.

mean

Numeric, the mean of the distribution.

sd

Numeric the standard deviation of the distribution.

Value

A vector of samples from the gamma distribution

Examples

## Example sample <- rgamma_with_mean_sd(1000, 2, 3) mean(sample)
#> [1] 1.921294
sd(sample)
#> [1] 2.818776
hist(sample)
## Code rgamma_with_mean_sd
#> function (n, mean, sd) #> { #> theta <- sd^2/mean #> k <- mean/theta #> stats::rgamma(n, shape = k, scale = theta) #> } #> <bytecode: 0x55a6b2087558> #> <environment: namespace:WuhanSeedingVsTransmission>