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

Results from separate seed() and set_stream() differ from two-argument seed() #91

Open
rstub opened this issue Apr 9, 2024 · 0 comments

Comments

@rstub
Copy link

rstub commented Apr 9, 2024

When I seed and set the stream separately I get a different result than if I do that with a single call. Is that expected?

Example code:

#include <iostream>
#include "pcg_random.hpp"

int main(void) {
  pcg64 rng;
  rng.seed(20240409);
  std::cout << rng << std::endl;
  rng.set_stream(90404202);
  std::cout << rng << std::endl;
  rng.seed(20240409, 90404202);
  std::cout << rng << std::endl;
  return 0;
}

Output:

47026247687942121848144207491837523525 117397592171526113268558934119004209487 232695090976826000214660542883178056279
47026247687942121848144207491837523525 180808405 232695090976826000214660542883178056279
47026247687942121848144207491837523525 180808405 324486960932314774260885781527366674683

I would have expected the second and third line to be identical. While that is true for the stream indicator (second number), this is not the case for the RNG state (third number).

@rstub rstub changed the title Results from separate seed() and set_stream() differ from two-arguemnt seed() Results from separate seed() and set_stream() differ from two-argument seed() Apr 9, 2024
rstub added a commit to daqana/dqrng that referenced this issue Apr 13, 2024
These methods have rather surprising properties, c.f. imneme/pcg-cpp#91. THis makes it impossible to get consistent results together with `clone(stream)`.
rstub added a commit to daqana/dqrng that referenced this issue Apr 15, 2024
* Add clone(stream) method for the RNGs and don't use two argument constructor/seed method for PCG

These methods have rather surprising properties, c.f. imneme/pcg-cpp#91. This makes it impossible to get consistent results together with `clone(stream)`.

* Add template methods to the RNG class to draw from a distribution

This new methods are also used where random variates are generated. The methods are inspired by Melissa O'Neill's `randutil`. Main adaption is that one needs to fully specify the distribution since the aliases dqrng::normal_distribution etc. are already fully specified. The original methods are also available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant