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.922839
sd(sample)
#> [1] 2.818425
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: 0x7ff900e9a6b0> #> <environment: namespace:NCoVUtils>