-
Notifications
You must be signed in to change notification settings - Fork 4
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
BUG: sampler occasionally hangs #83
Comments
Hi @martinjankowiak thank you once again for reporting any bugs you come across. This is a great opportunity for me to fix any weaknesses in the implementation that I was not aware of. Since I have no idea how many people are using this package I only have had my own use cases as a way of "testing" the library's quality. I can definitely reproduce this issue locally, and it sure does go away when I remove the Lines 27 to 46 in da31ac8
I see that a very small -x or x=0 can be generated as a proposal sample during the accept-rejection sampling which can throw off the sampler and cause it to hang. So I re-introduced the check for positive x in the piecewise_coef function and then voila! The hang disappeared.
Because re-introduction of that line should not affect the sequence of the states, then I think we can be confident that the cause of the hang was likely that a value of |
A little extra digging shows the source of this issue with the proposal sample Line 133 in da31ac8
When
The above is the standard output of the values in the line where it happens. According to my findings, it happens for the element So it seems like real solution is to ensure that the sign of the expression inside the sqrt is not negative in the case that it evaluates to zero. A bit of algebra shows that the expression inside the sqrt can be re-written as: |
@martinjankowiak I've put out an alpha release for your immediate use at https://pypi.org/project/polyagamma/1.3.2a0/. Let me know if you run into any issues. Hopefully #80 can be solved soon so I can put out an official release. |
hello @zoj613. thanks again for the great package. i'm sometimes seeing the sampler stall/hang.
this is the smallest reproducible script i've been able to come up with. hopefully this will surface the issue on your system as well...
The text was updated successfully, but these errors were encountered: