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

Index error when number of samples is not a multiple of 10 #20

Closed
kdolum opened this issue Aug 17, 2021 · 3 comments
Closed

Index error when number of samples is not a multiple of 10 #20

kdolum opened this issue Aug 17, 2021 · 3 comments
Assignees
Labels

Comments

@kdolum
Copy link
Collaborator

kdolum commented Aug 17, 2021

I say sampler.sample(x0, 128, SCAMweight=30, AMweight=15, DEweight=50) and I get IndexError: index 12 is out of bounds for axis 0 with size 12. 12 is the quotient of 128 over 10. It seems to be completely repeatable, giving an error for any number of samples that is not a multiple of 10.

@paulthebaker paulthebaker self-assigned this Aug 17, 2021
@paulthebaker
Copy link
Member

paulthebaker commented Aug 17, 2021

It looks like the issue comes from when the chain arrays get initialized at PTMCMCSampler.py#L182. The default thin is 10. The issue occurs whenever Niter/thin is not an integer ratio. For instance

sampler.sample(p0, 128, thin=8)

works correctly. It looks like it would be solved by justing adding 1 to N.

@paulthebaker
Copy link
Member

Adding 1 to N causes an extra unused index at the end of the arrays with Niter/burn is an integer ratio. It seems the best thing to do is round:

N = int(np.ceil(maxIter / thin))

@kdolum
Copy link
Collaborator Author

kdolum commented Nov 17, 2023

Fixed by #41.

@kdolum kdolum closed this as completed Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants