Julia v0.7 and older
In Julia, you can set a seed to the random number generator using the srand()
function. The code example below sets the seed to 1234. Generating a random variable with rand(1)
after setting the seed to 1234 will always generate the same number, i.e. it will always return 0.5908446386657102.
srand(1234) rand(1)
Julia 1.0 and younger
In the new Version of Julia, the syntax to set a seed to the random number generator changes. You are now supposed to use seed!()
from the Random
package.
using Random Random.seed!(1234) rand(1)