dfm / emcee

The Python ensemble sampling toolkit for affine-invariant MCMC
https://emcee.readthedocs.io
MIT License
1.47k stars 430 forks source link

invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] #370

Open SwastikC opened 3 years ago

SwastikC commented 3 years ago

Hi. I am getting this warning/error everytime. Can you please help me .. :(

0%| | 0/500 [00:00<?, ?it/s]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] /home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 0%|▎ | 1/500 [00:32<4:27:17, 32.14s/it]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] /home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 0%|▋ | 2/500 [01:07<4:35:28, 33.19s/it]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 1%|▉ | 3/500 [01:43<4:40:44, 33.89s/it]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] /home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 1%|█▎ | 4/500 [02:20<4:48:14, 34.87s/it]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] /home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 1%|█▋ | 5/500 [02:57<4:52:05, 35.41s/it]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] /home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 1%|█▉ | 6/500 [03:39<5:09:31, 37.59s/it]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] /home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 1%|██▎ | 7/500 [04:16<5:06:44, 37.33s/it]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 2%|██▌ | 8/500 [04:57<5:15:00, 38.42s/it]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] /home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 2%|██▉ | 9/500 [05:37<5:17:48, 38.84s/it]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 2%|███▎ | 10/500 [06:17<5:21:14, 39.34s/it]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] /home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 2%|███▌ | 11/500 [06:55<5:15:22, 38.70s/it]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] /home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 2%|███▉ | 12/500 [07:36<5:20:49, 39.45s/it]/home/swastik/anaconda3/lib/python3.8/site-packages/emcee/moves/red_blue.py:99: RuntimeWarning: invalid value encountered in double_scalars lnpdiff = f + nlp - state.log_prob[j] 3%|████▏

dfm commented 3 years ago

This probably means that there's a bug in your probability function. Please provide more details and try to put together a minimal example of a code snippet that can be run to reproduce this. This must be minimal (i.e. no dependencies and no real data) because the point is to isolate the issue.

SwastikC commented 3 years ago

Hi .. I solved this issue... Some of the priors were generated randomly outside the range I wanted and so it was making them -inf. So this was the cause of the error.

ayushp88 commented 2 years ago

SwastikC I am also facing the same error, can you please tell me how you resolved it?

EmmaLitzer commented 2 years ago

Hi I am also having this issue with the same error code, @SwastikC how did you resolve your prior generating outside of the range? I unfortunately have 17 priors and cannot manually go through each one for all of my simulations. Any help would be appreciated.

SwastikC commented 2 years ago

Hi. @ayushp88 and @EmmaLitzer This is a normal math error and a warning in the code. This happens when one of your initial guess values falls outside the range you defined in the prior function. Basically it wont be taken into consideration for your runs and won't effect your final result. If you want to ignore this error just use np.seterr(all="ignore"). Again this will not not affect your error and your convergence for other point. If you still have doubt drop me a mail. swastik.chowbay@iiap.res.in