Generate random number following gaussian distribution

I know rand() will generate a random number following unif(0,1), but how to generate a random number following gaussian distribution? Is there an existing function?

randn()

1 Like

randn will generate a number according to the standard normal distribution.

If you want other distributions as well do

using Distributions

rand(Normal(0,1))
rand(Gamma(3,1))
...etc
1 Like