Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overloads for combinatorics.jl methods that accept rng's as parameters #10345

Closed
kyle-pena-nlp opened this issue Feb 27, 2015 · 1 comment · Fixed by #10349
Closed

overloads for combinatorics.jl methods that accept rng's as parameters #10345

kyle-pena-nlp opened this issue Feb 27, 2015 · 1 comment · Fixed by #10349
Labels
domain:randomness Random number generation and the Random stdlib

Comments

@kyle-pena-nlp
Copy link

It would be cool if we had some overloads for functions in combinatorics.jl (like randperm and shuffle) that accept an rng as an argument.

Using the global rng works fine 99% of the time, but that 1%! Gah!

Here's a contrived example:

# seed the global rng
srand(42)

# do something random a non-deterministic number of times
for line in lines_in_a_file shuffle(collect(1:10)) end

# later, do a shuffle on something unrelated
shuffle(collect(1:10))

Global seeding is great, but if you invoke rand() a non-deterministic number of times... well the global rng is a non-deterministic state there on out, so you can't really get deterministic behaviour out of it unless you reinitialize it like so: srand(42).

I guess that's fine, but doesn't that approach break down when you get into distributed computation?

Anywho, I'm trying to make a case for always including overloads that accept an rng, in any method, not sure how successful the point is coming across.

I'm happy to pick it up as an issue unless someone else would rather give it a shot.

@simonbyrne
Copy link
Contributor

Yes, I would like to see all methods which use rand accept an RNG as an argument: see #8786.

simonbyrne added a commit to simonbyrne/julia that referenced this issue Feb 27, 2015
@simonbyrne simonbyrne added the domain:randomness Random number generation and the Random stdlib label Feb 27, 2015
simonbyrne added a commit to simonbyrne/julia that referenced this issue Mar 10, 2015
simonbyrne added a commit to simonbyrne/julia that referenced this issue Mar 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:randomness Random number generation and the Random stdlib
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants