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

small deterministic example update #1240

Merged
merged 3 commits into from
Aug 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions examples/rayon-monte-carlo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ fn main() {
.into_par_iter()
.map(|i| {
let mut rng = ChaCha8Rng::seed_from_u64(SEED);
// We chose ChaCha because it's fast, has suitable statical properties for simulation,
// and because it supports this set_stream() api, which lets us chose a different stream
// We chose ChaCha because it's fast, has suitable statistical properties for simulation,
// and because it supports this set_stream() api, which lets us choose a different stream
// per work item. ChaCha supports 2^64 independent streams.
rng.set_stream(i);
let mut count = 0;
Expand All @@ -69,7 +69,10 @@ fn main() {
}
count
})
.reduce(|| 0usize, |a, b| a + b);
.sum::<usize>();

// assert this is deterministic
assert_eq!(in_circle, 7852263);

// prints something close to 3.14159...
println!(
Expand Down