hildensia / bayesian_changepoint_detection

Methods to get the probability of a changepoint in a time series.
MIT License
670 stars 213 forks source link

'FloatingPointError: underflow encountered in logaddexp' occurs when setting np.seterr(all='raise') #24

Open alatif-alatif opened 3 years ago

alatif-alatif commented 3 years ago

Hi,

I installed _bayesian_changepointdetection from this github repository.

By setting (accidentally) np.seterr(all='raise'), I was able to cause the following exception.

I am not sure whether this would have any relevance for the further processing, but I just wanted to draw attention to people working on / with this library.

/home/user/venv/env01/bin/python3.6 /home/user/PycharmProjects/project01/snippet.py
Use scipy logsumexp().
Traceback (most recent call last):
  File "/home/user/PycharmProjects/project01/snippet.py", line 68, in <module>
    Q, P, Pcp = offcd.offline_changepoint_detection(data, partial(offcd.const_prior, l=(len(data) + 1)), offcd.gaussian_obs_log_likelihood, truncate=-40)
  File "/home/user/experiments/original-unforked/bayesian_changepoint_detection/bayesian_changepoint_detection/offline_changepoint_detection.py", line 98, in offline_changepoint_detection
    Q[t] = np.logaddexp(P_next_cp, P[t, n-1] + antiG)
FloatingPointError: underflow encountered in logaddexp

Process finished with exit code 1