Generate Gamma Distributed Numbers in Julia

In Julia, one can generate random numbers that follow a Gamma distribution by using the Distribution package. Thereby one can use the rand() function that draws random numbers and specify the Gamma distribution by using the Gamma(a,b) command. The parameters a and b define the shape parameters of the Gamma distribution. This article provides a more generic overview of how to generate random numbers in Julia.

The following code example generates the variable A that contains 10 random numbers that follow a Gamma distribution with shape 1 and 2.

using Distributions 
A = rand(Gamma(1,2),10)

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.