Numerically stabilize autocorrelation()#3114
Merged
Merged
Conversation
Collaborator
martinjankowiak
left a comment
There was a problem hiding this comment.
is this the right fix? under what circumstances does autocorr[..., :1] get small?
Member
Author
|
Yeah I don't know if this is the right fix. The issue is when one value doesn't vary at all, so in that case I think the autocorrelation should be 1. |
Collaborator
|
would it make sense to e.g. add an explicit test that checks that the resulting effective sample size is small for a variable with zero variance? |
Member
Author
|
OK I've added some tests.
hmm, it looks like our |
martinjankowiak
previously approved these changes
Jul 8, 2022
martinjankowiak
approved these changes
Jul 9, 2022
Member
Author
|
Thanks for reviewing! |
OlaRonning
pushed a commit
to aleatory-science/pyro
that referenced
this pull request
Aug 2, 2022
* Allow autocorrelation() to run without mkl * Numerically stabilize * Clarify definition, add test * Remove xfail_if_not_implemented
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This sets the autocorrelation of constant series to be 1.0 rather than NAN.
I believe this is the proper behavior for MCMC testing, where series with no variation should be seen as having effective sample size of 1.
My use case is in computing autocorrelation of discrete time series, where I'm using autocorrelation as a diagnostic to detect lack of mixing. In that case I believe this PR is correct.
Tested