Getting `divide by zero` warning when not storing chain in memory
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.6k
- Forks
- 440
- PR merge metrics
- No merged PRs in 30d
Description
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:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the warning with sampler.sample(..., store=False) and inspect how the backend's accepted and iteration state is updated. Trace the acceptance_rate calculation and confirm that a run without storing the chain reports a valid rate without a division-by-zero warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100