-
Notifications
You must be signed in to change notification settings - Fork 21
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
Using Latin hypercube sampler for Prior.draw
#521
base: main
Are you sure you want to change the base?
Using Latin hypercube sampler for Prior.draw
#521
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. However, I find one thing worse with change. Looks like you cannot re-produce exactly the example results anymore every time you run them. I guess that is because you should fix somehow the seed of this new Latin hypercube sampler.
For example, if running TestRun_BB.py twice in a row, I get first time:
The support occupies an estimated 25.4% of the hypervolume within the unit hypercube...
Fractional hypervolume estimated.
Sampling efficiency set to: 3.1504.
And second time:
The support occupies an estimated 24.8% of the hypervolume within the unit hypercube...
Fractional hypervolume estimated.
Sampling efficiency set to: 3.2264.
Previously, fixing the numpy seed in the main script was enough to guarantee the numbers won't change here when executing several times.
Perhaps you could fix the seed for this hypercube sampler in all the example files, so that they remain very re-producible. Adding something similar to this line:
|
@thjsal it wasn't as straightforward a fix. I've added a |
Seems like it is not working for me. I get first (when running TestRun_BB.py):
That I can fix by doing Then I get
Seems like the "rng" input parameter was used to be named "seed" in Scipy version before 1.15. Do you think we should force X-PSI to use Scipy versions newer than this (it also requires Python newer than 3.10)? Anyway, I changed that to "seed", but now I get:
I don't know yet how to solve this one. |
Thanks for fixing the However, looking at your error, it also seems that the error is taking place at an earlier/later point, i.e. at It's not immediately obvious to me why the second error arises though |
I think it may use the latest Scipy version if creating the X-PSI environment now. But probably the version v1.15 was not yet available when we last time created that environment. I don't know if upgrading to that version would cause issues. Looks like at least the Github CI-tests are already using that version without issues. But would be good to add another CI-test for drawing samples, and calling the sampler (this is not tested currently). If we do that, we should also stop testing Python 3.8 and Python 3.9 as those would not work anymore. Alternatively, we could call the parameter "seed", since it should still work, probably just giving a deprecation warning for now. Regarding the latest error, I found that is caused because giving input arguments for a property function is not allowed. The error goes away if not declaring the Next error is from pymultinest which is not happy that it got an additional
|
Now unit_hypercube_frac is also not a property function anymore.
Okay, pushed now fixes to all the errors mentioned above. The last one (pymultinest error) was solved by just not having LHS_seed defined in the kwargs that are sent to pymultinest. Now the test runs seem to work as intended. But perhaps should still check/think if the removal of the "@Property" definition from I am also planning to set up (maybe in a couple of days) one or two new Github CI-tests to make sure the sampling works also with newest packages. |
I also changed |
The For the pymultinest error, if you didn't pass it via the |
|
Ah right, I was looking at the main branch where it was still called as a method. In any case, let's hear the opinion of others on Python & SciPy updates, then make the appropriate changes before merging the pull request |
I made another pull request for the CI tests to be merged to this branch (#525 ). There I confirmed that indeed if using the "rng" argument instead of "seed", the tests only pass if using python3.10 or newer: https://github.com/xpsi-group/xpsi/actions/runs/13408191787 But they all pass if using "seed". The exact value of the estimated prior volume using by either "seed" or "rng" is though different and needs to be changed depending on which one is used. Now I assume "seed" is used. |
Addresses feature request #520.
I have checked its expected application on the modelling notebook where we print the outputs of
Prior.draw
. The prior distributions looked ~identical, perhaps even slightly more uniformly distributed than before as seen by eye.