dfm / dfm/emcee

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

Open
#329 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Request
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.