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

Problem with rng/seed of rgalsim.random.GaussianDeviate #5

Open
Hbretonniere opened this issue Nov 4, 2020 · 4 comments
Open

Problem with rng/seed of rgalsim.random.GaussianDeviate #5

Hbretonniere opened this issue Nov 4, 2020 · 4 comments

Comments

@Hbretonniere
Copy link

While gaslim.BaseDeviate takes a random generator (which is what we want), galsim.GaussianDeviate takes a seed.

We need a method which takes a rng, but with which we can also generate vectors (sampling).

@Hbretonniere
Copy link
Author

Hbretonniere commented Nov 4, 2020

Actually galsim.GaussianDeviate can take a rng instead of a seed... So maybe there s no problem at all...

But Actually I don't understand why do we create again an rng inside the sample method... (gd = galsim.GaussianDeviate(rng))

Why don t we just do :

sample(rng):
   if rng=None:
      rng = galsim.GaussianDeviate(rng).  # because rng=None, it means we don t have any control on the seed of the GD
   if random nornal...:     # for the flow
      noise = np.empty(...)
      # no gd = new rng
      rng.generate(noise)     # gaussiandeviates actually has a generate method, inheritate it fron basedeviate

If you want a control on the seed, you create the rng outside the function, with :
rng = galsim.GaussianDeviate(seed), and pass the rng to the sample method.

@Hbretonniere
Copy link
Author

I've tried it, it looks like it works. I can share you my version if you think it's the good solution.

@EiffL
Copy link
Member

EiffL commented Nov 5, 2020

Ok nice :-) And it works with both GalSim 1.15 and 2.x?

@EiffL
Copy link
Member

EiffL commented Nov 5, 2020

And yes, for sure, feel free to submit a PR, I'll be happy to review it

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

2 participants