Hello, today I worked with generating random gamma distributions with known parameters, therefore, I would like to share my codes and comments regarding to a data generation process of a gamma distribution in R. Gamma distribution is a two-parameter continues probability distribution. The first parameter is called shape parameter and the second parameter is called scales parameter.

The shape parameter is calculated by mu^2/sigma^2 and scale parameter is calculated by sigma^2/mu. Therefore given both parameters, we can generate a random gamma distribution with a known number of people (n).

Here it goes.

gamma.gen <- rgamma(1000, 0.5, scale=0.01)

1000 is the sample size, 0.5 is the shape parameter and .01 is the scale parameter.

The histogram of the distribution looks like:

hist(gamma.gen)

The distribution is very similar to chi-square distribution, which is actually a special case of the gamma distribution.

Best.

Seyfullah.