emcee icon indicating copy to clipboard operation
emcee copied to clipboard

Getting `divide by zero` warning when not storing chain in memory

Open Thalos12 opened this issue 6 years ago • 1 comments

General information:

  • emcee version: 3.0.0
  • platform: Ubutnu 18.04
  • installation method (pip/conda/source/other?): conda (conda-forge)

Problem description:

Expected behavior:

I would expect emcee to be able to return the acceptance rate even when the chain is not stored in memory.

Actual behavior:

When the chain is not stored in memory (I am using sampler.sample([other args], store=False) and saving to file manually) there is a warning about a division by zero and sampler.acceptance_rate always returns NaN.

What have you tried so far?:

I tried to determine why this is happening. As far as I understood, with save=False the accepted and iteration attributes of the backend are initialized to an array of zeroes and zero respectively, but then never updated, because it only happens if backend.save_state is called. For this reason, any call to sampler.acceptance_rate will trigger a warning about the division by zero.

Minimal example:

Thalos12 avatar Nov 08 '19 14:11 Thalos12

Thanks for the report! I think it's a good suggestion to enable this behavior (it doesn't work currently because the state is entirely encoded via the backend) and I'll look into adding it.

dfm avatar Nov 11 '19 13:11 dfm