question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RuntimeWarning: invalid value encountered in double_scalars

See original GitHub issue

General information:

  • emcee version: 2.2.1
  • platform: Ubuntu LTS 18.04
  • installation method (pip/conda/source/other?): pip

Problem description:

Expected behavior:

No error

Actual behavior:

I get a RuntimeWarning: invalid value encountered in double_scalars in the red_blue.py script at line 97: lnpdiff = f + nlp - state.log_prob[j]. The same error appears from the old ensemble.py script at the line: lnpdiff = (self.dim - 1.) * np.log(zz) + newlnprob - lnprob0 (Issue 269, now closed)

What have you tried so far?:

I have tried both versions of the code, and I can’t figure out why I get that error. For an Ensemble with a lower amount of steps I do not get that error, only when the chain gets longer.

Minimal example:

import emcee



# sample code goes here...

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dfmcommented, May 8, 2019

This generally means that you are initializing in some part of parameter space where the log probability is -inf or nan. Double check that your initialized values are all ok. If they are, then there’s a chance that this is caused by your log probability function returning nan or inf, but that should be caught in the sampler. One way or another you should always try to catch issues like that in your log probability function and return -np.inf. Give that a shot.

0reactions
ayushp88commented, Jan 5, 2022

I’m not sure what you mean by “control”, but this does mean that there’s some numerical issue happening in your log probability function and it normally has to do with initialization. I’d recommend trying to make a simple test case that reproduces the problem. That should make it clear what’s going on.

Sir I am also facing the same issue, can you please help me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

runtimewarning: invalid value encountered in double_scalars
This error occurs when you attempt to perform some mathematical operation that involves extremely small or extremely large numbers and Python ...
Read more >
python - numpy division with RuntimeWarning: invalid value ...
It seems to be that the input element were too small that python turned them to be zeros, but indeed the division has...
Read more >
How to Fix: runtimewarning: invalid value encountered in ...
This error simply occurs when we performing a math operation and we encounter which is not valid as input. When we perform some...
Read more >
PYTHON : 'invalid value encountered in double_scalars ...
PYTHON : ' invalid value encountered in double_scalars ' warning, possibly numpy [ Gift : Animated Search Engine ...
Read more >
invalid value encountered in double_scalars - PYTHON
PYTHON : numpy division with RuntimeWarning : invalid value encountered in double_scalars [ Gift : Animated Search Engine ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found