keisoku

Gamma Distribution Random Generator

Generate random numbers from a gamma distribution with shape k and scale theta. Shows a sample list, histogram, sample mean and sample variance.

Input

Enter the shape parameter k, the scale parameter theta and the number of samples, then press generate to draw random numbers from a gamma distribution.

k
theta
samples

You can choose from 1 to 10000 samples.

Result

Enter the parameters and press generate to see the random numbers and histogram here.

How it works

  • Enter the shape parameter k (k greater than 0), the scale parameter theta (theta greater than 0) and the number of samples, then press the generate button to draw random numbers from a gamma distribution. New samples are produced each time you press the button.
  • Samples are generated with the Marsaglia-Tsang method. It is valid when the shape k is at least 1, so for k below 1 the value is drawn with shape k plus 1 and corrected by multiplying with a uniform variate raised to the power one over k. Standard normal variates come from the Box-Muller method.
  • The theoretical mean of a gamma distribution is k times theta, and the theoretical variance is k times theta times theta. The sample mean and sample variance of the generated numbers approach these theoretical values, and the agreement improves as the count grows.
  • The histogram splits the range from the minimum to the maximum sample into equal-width intervals and shows the frequency of each interval as a bar. The number of intervals is chosen automatically based on the count, up to 20 intervals.
  • You can generate up to 10000 samples. Only the first part of the sample list is shown, and the remaining values are reported as a count. Use this tool for statistics study and for checking simulation behavior.

Reviews

Tell us what you think of this calculator.

Write a review

  1. Home
  2. Gamma Distribution Random Generator