Giter VIP home page Giter VIP logo

Comments (6)

ShixiangWang avatar ShixiangWang commented on June 27, 2024

Thanks for the response. But if I could not reproduce the rand with specified random seed operation by seed!(123), what's the point to use the my_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

from juliadatascience.

storopoli avatar storopoli commented on June 27, 2024

@ShixiangWang have you seen the new note?

NOTE:

Note that these numbers might differ for different Julia versions.
To have stable streams across Julia versions use the StableRNGs.jl package.

from juliadatascience.

rikhuijzer avatar rikhuijzer commented on June 27, 2024

what's the point to use the my_seed?

Also the most important thing about using a seed is usually to have a reproducible workflow when developing. When developing, it is common to run one part of the code for dozens of times. Debugging is much easier when the output is the same for each run.

from juliadatascience.

rikhuijzer avatar rikhuijzer commented on June 27, 2024

Due to HTTP issues in the automated workflow, the book isn't updated yet. Azure has some outages (https://news.ycombinator.com/item?id=29574027), so that is probably related.

I'll click retry a few times, so the book should be updated somewhere today.

from juliadatascience.

ShixiangWang avatar ShixiangWang commented on June 27, 2024

Hi guys, I think you mistake my point above. I do agree the random seed is very important.

We can reproduce the sequence generation with command below.

julia> using Random: rand, randn, seed!

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

julia> rand(3)
3-element Vector{Float64}:
 0.521213795535383
 0.5868067574533484
 0.8908786980927811

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

julia> rand(3)
3-element Vector{Float64}:
 0.521213795535383
 0.5868067574533484
 0.8908786980927811

However, in the book, as the code below cannot reproduce the same sequence, why the book still describe it. I think current text is misguiding readers. my_seed = seed!(123) is still useless, right? as the rand(my_seed, 3) can't reproduce same result when we type it again.

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

This is not a bug in Julia, as I get similar result (put my_seed in rand does not help reproduce the sequence) when I use v1.3.1 from https://cn.julialang.org/learning/tryjulia/

julia version 1.3.1

 using Random: rand, randn, seed!

 my_seed = seed!(123)
Random.MersenneTwister(UInt32[0x0000007b], Random.DSFMT.DSFMT_state(Int32[1464307935, 1073116007, 222134151, 1073120226, -290652630, 1072956456, -580276323, 1073476387, 1332671753, 1073438661  …  138346874, 1073030449, 1049893279, 1073166535, -1999907543, 1597138926, -775229811, 32947490, 382, 0]), [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0  …  0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], UInt128[0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000  …  0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000], 1002, 0)

 rand(my_seed, 3)
3-element Array{Float64,1}:
 0.7684476751965699
 0.940515000715187
 0.6739586945680673

 rand(my_seed, 3)
3-element Array{Float64,1}:
 0.3954531123351086
 0.3132439558075186
 0.6625548164736534

from juliadatascience.

rikhuijzer avatar rikhuijzer commented on June 27, 2024

As I said. The book is still in the process of being updated.

my_seed = seed!(123) is still useless, right?

No it is not. See the discussion above.

from juliadatascience.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.