The PMFT function triggers a `RuntimeWarning: divide by zero encountered in log`

Issue #192 resolved
Carl Simon Adorf created an issue

Specifically when calling pmft.PMFT.

Version : 0.11.0.

Comments (7)

  1. Bradley Dice

    @csadorf Yes, this happens any time you have a bin with zero counts. This is common in PMFTs if they haven't been extremely well sampled. What do you think should be the expected behavior? I am concerned that hiding the warning might conceal the fact that there will be NaNs produced from zero-bin-counts when the PMFT is computed from the negative log of the PCF.

  2. Carl Simon Adorf reporter

    I think that it's fine to have an output including nan values, but the warning is very confusing.

    Should I actually be concerned about it? Do I need to do something about it? Or is this more or less expected behavior, then there should not be any warning.

  3. Vyas Ramasubramani

    Since this is always the expected behavior, I agree that this is annoying and probably unnecessary, and have been meaning to address this. However, I'm not yet sure what the ideal solution is. Intuitively you would want to replace the nans with infinities; the main issue there I think is that it would behave differently for visualization. We should fix this one way or another though.

  4. Bradley Dice

    I think we should just hide the warning and continue to return nans. I don't think that infinity is the right choice -- in many bins, it's a problem of no sampling, not truly infinite barriers to that configuration (exception: the barrier is actually infinite for the hard core of a hard particle, but the bins that weren't sampled outside that particle make more sense to remain "undefined" in a sense, and we don't have a way to know the difference).

  5. Vyas Ramasubramani

    Given that we also don't know the shape, we also don't have a way to know what's "inside the shape"; what if is just poorly sampled in some sense? But I agree, I'm not sure if infinity is really more indicative of anything than NaN. Maybe we just suppress the warning.

  6. Carl Simon Adorf reporter

    I didn't look at PR #239 (I'm having trouble loading it on airport wifi), but it what probably be a good idea to document this behavior somewhere. Ignore this comment if that's already the case.

  7. Log in to comment