samedi 11 décembre 2021

Julia cannot reproduce the rand

I am just reading and practicing the "3.5.2.1 rand" section of https://juliadatascience.io/standardlibrary and found the code below cannot reproduce same random numbers:

$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.0 (2021-11-30)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Random: rand, randn, seed!

julia> my_seed = seed!(123)
Random.TaskLocalRNG()

julia> rand(my_seed, 3)

3-element Vector{Float64}:
 0.521213795535383
 0.5868067574533484
 0.8908786980927811

julia> rand(my_seed, 3)
3-element Vector{Float64}:
 0.19090669902576285
 0.5256623915420473
 0.3905882754313441

The snapshot of the book:

enter image description here




Aucun commentaire:

Enregistrer un commentaire