small errors emcee

2,081 views
Skip to first unread message

Hiram Lucatero

unread,
Jul 25, 2017, 2:51:59 PM7/25/17
to lmfit-py
Hello!
I'm trying to do the contours plots with the module corner using the results of emcee fit , but the fitted parameter's values appears to have a small stderr (around 0.01%)  and I got the warning: too few points to create valid contours 

This image shows the result of the fit:


The first variable values are the result of using lmfit.Minimizer and the second ones are the result of the emcee, as you can see the stderr is too small.

Is there a way to fix that small stderr? I think that is the reason why corner can not make the valid contours.

I attached the code in mb-IBEGx-abs.py and the data in SCPunion21-Ordenado.txt


Thx for your help!




SCPunion21-Ordenado.txt
mb-IBEGx-abs.py

Nicholas Farrow

unread,
Dec 11, 2017, 12:56:29 AM12/11/17
to lmfit-py
I am having the same issue. Did you ever find a solution?

Matt Newville

unread,
Dec 11, 2017, 9:24:33 AM12/11/17
to lmfit-py
Hi,


On Sun, Dec 10, 2017 at 11:56 PM, Nicholas Farrow <nicholas...@gmail.com> wrote:
I am having the same issue. Did you ever find a solution?



Sorry, I'm not exactly sure where the message " warning: too few points to create valid contours " comes from.  I think that is not from lmfit, but perhaps it is from emcee?


Can you please post a minimal example that shows the problem and full output?


 

--
You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmfit-py+unsubscribe@googlegroups.com.
To post to this group, send email to lmfi...@googlegroups.com.
Visit this group at https://groups.google.com/group/lmfit-py.
To view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/9324cee9-d50f-4b3e-b71e-c1af53e04da8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--Matt

Peter Metz

unread,
Dec 13, 2017, 10:38:39 PM12/13/17
to lmfit-py
I can confirm this error is coming from corner or a module corner depends on.

Simple test case attached.

I would check the emcee documentation and the paper they reference on their landing page. nwalkers (e.g. population size) should be >>> nvariables, and a certain number of steps (e,g, generations) are required for "convergence." 

Check the length of the flatchain attribute of your emcee result- for a handful of parameters mine are usually 10's of thousands in length (although it will depend on your particular case).

Cheers,
Peter


On Monday, December 11, 2017 at 9:24:33 AM UTC-5, Matt Newville wrote:
Hi,


On Sun, Dec 10, 2017 at 11:56 PM, Nicholas Farrow <nicholas...@gmail.com> wrote:
I am having the same issue. Did you ever find a solution?



Sorry, I'm not exactly sure where the message " warning: too few points to create valid contours " comes from.  I think that is not from lmfit, but perhaps it is from emcee?


Can you please post a minimal example that shows the problem and full output?


 

On Wednesday, July 26, 2017 at 4:51:59 AM UTC+10, Hiram Lucatero wrote:
Hello!
I'm trying to do the contours plots with the module corner using the results of emcee fit , but the fitted parameter's values appears to have a small stderr (around 0.01%)  and I got the warning: too few points to create valid contours 

This image shows the result of the fit:


The first variable values are the result of using lmfit.Minimizer and the second ones are the result of the emcee, as you can see the stderr is too small.

Is there a way to fix that small stderr? I think that is the reason why corner can not make the valid contours.

I attached the code in mb-IBEGx-abs.py and the data in SCPunion21-Ordenado.txt


Thx for your help!




--
You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmfit-py+u...@googlegroups.com.

To post to this group, send email to lmfi...@googlegroups.com.
Visit this group at https://groups.google.com/group/lmfit-py.


--Matt
too_few_points.py

Matt Newville

unread,
Dec 14, 2017, 12:21:10 PM12/14/17
to lmfit-py
Thanks Peter,

On Wed, Dec 13, 2017 at 9:38 PM, Peter Metz <pet...@gmail.com> wrote:
I can confirm this error is coming from corner or a module corner depends on.

Simple test case attached.


That's very helpful.  To me it looks like that fit isn't really doing anything meaningful -- the fit might be a bit too simple and there are no uncertainties estimated by the `run_opt` portion.  Maybe that's what makes the contours too small?

But that's probably what is really causing the trouble.  It does look like the problem might be with corner not handling small uncertainties, but it would be nice to verify that....

 
To unsubscribe from this group and stop receiving emails from it, send an email to lmfit-py+unsubscribe@googlegroups.com.

To post to this group, send email to lmfi...@googlegroups.com.
Visit this group at https://groups.google.com/group/lmfit-py.

For more options, visit https://groups.google.com/d/optout.


--Matt

Peter Metz

unread,
Dec 14, 2017, 1:52:36 PM12/14/17
to lmfit-py


Hi Matt,

Perhaps my example was unclear. The "optimization" is simply matching a straight line, which may as well be analytic. It's just a dummy method that will evaluate quickly.

The point I mean to illustrate is that if the population size / number of generations is too small (e.g. your number of posterior samples is too small) the "Too Few Points" warning is generated. This is clear if you play with the population size (nwalkers) and generations (nsteps) and burn paramters- two examples below.

In this example there is no noise / uncertainty, so the estimated uncertainty should be vanishingly small. With the larger sample population (1500 steps, 100 walkers, 750 burnt) the uncertainty at +- 1 sigma is around 5e-07. Doubling the number of steps (~doubling the population) makes essentially no change.

-Peter


Figure: nsteps=1500, nwalkers=100, burn=750, workers=1



Bounded Values:
----------------------------------------------------------------
+  m : 1.00000000134 + 8.26231999707e-07 - 8.2724548478e-07
+  b : 1.99999999837 + 4.35335232973e-07 - 4.35814465849e-07
+  f : 1.00695068483e-06 + 1.22565923764e-08 - 5.28530692709e-09




Figure: too few samples (this raises the error) nsteps=1000, nwalkers=24, burn=100, workers=1
Thanks Peter,



--Matt
Reply all
Reply to author
Forward
0 new messages