pyro-ppl / numpyro

Probabilistic programming with NumPy powered by JAX for autograd and JIT compilation to GPU/TPU/CPU.
https://num.pyro.ai
Apache License 2.0
2.15k stars 234 forks source link

autocorrelation function #1828

Closed jecampagne closed 2 months ago

jecampagne commented 3 months ago

Hello, May be I have not using the "autocorrelation" correctly but in case I post the snippet on Colab HERE. The result is that the Arviz auto-corr seems ok image

while the numpyro function exhibits a strange behavior image

Any idea?

jecampagne commented 3 months ago

Well looking at the code In numpyro there is a line

 autocorr = autocorr / np.arange(N, 0.0, -1)

while the arviz.autocorr output agree if I replace the above line by

autocorr = autocorr / autocorr[0]

image

fehiepsi commented 3 months ago

Could you use the change in #1785? It seems that we also divide autocorr[0] at this line

jecampagne commented 3 months ago

Ok thanks @fehiepsi, so I understand the pb and probably a solution would be to have a flag to switch from one to the other normalisation schema.

fehiepsi commented 3 months ago

I think we can change the behavior. No need for a new flag. Do you want to submit a PR?

fehiepsi commented 2 months ago

Closed because this is a duplication of https://github.com/pyro-ppl/numpyro/issues/1785