Skip to content

Documentation: Clarify that to use StableRNGs one must give a rng to every rand() call instead of setting Random.seed!()Β #13

@eirikbrandsaas

Description

@eirikbrandsaas

Hi, thanks for this package. Very useful as my computational cluster doesn't update Julia frequently.

Issue:
I think many just set Random.seed!() and forget about it. Then for some reason they need to use StableRNGs, at which point the natural starting point is something like Random.seed!(StableRNG(seed::Integer)) which doesn't work. (e.g., https://discourse.julialang.org/t/random-seed-lts-vs-latest-stable/64370).

The usage section could maybe just have an extra subsection at the end of readme.md, along the lines of:

Moving from Random.seed!() to StableRNGs

If you in previous code used `Random.seed!() to get the same random numbers, you most now modify all calls that generate random numbers. For example, if your old code was:

Random.seed!(1)
rand()

It should be:

using StableRNGs
rng = StableRNG(1) # Note that we don't use `Random.seed!()` anymore as it is redundant.
rand(rng,)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions