Multiple starting points

103 views
Skip to first unread message

DARRYNK

unread,
Jul 29, 2022, 7:02:57 AM7/29/22
to lmfit-py
Is there a method that I can fit a model, with 2 different starting points, at the same time and then select the best fit? Obviously I can run one after the other, but this isn't efficient. Can I run a composite model like this? All the documentation for composite models pass in the same parameters.

Renee Otten

unread,
Jul 29, 2022, 8:05:06 AM7/29/22
to lmfi...@googlegroups.com
You could use a method like “brute” (not parallel) or “differential_ecolution” (can be be run in parallel I think). But also, how inefficient is it for real to do a few different starting points sequential…

Renee

On Jul 29, 2022, at 7:03 AM, 'DARRYNK' via lmfit-py <lmfi...@googlegroups.com> wrote:

Is there a method that I can fit a model, with 2 different starting points, at the same time and then select the best fit? Obviously I can run one after the other, but this isn't efficient. Can I run a composite model like this? All the documentation for composite models pass in the same parameters.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/75e7704d-d9c6-444e-aae6-29de440b2b6en%40googlegroups.com.

DARRYNK

unread,
Jul 29, 2022, 9:02:01 AM7/29/22
to lmfit-py
Hi Renee,

Sorry, I should have said that I'm using least squares as the method. I'm using this in an application, so running it twice will double the response time.

Darryn

Renee Otten

unread,
Jul 29, 2022, 9:21:07 AM7/29/22
to lmfi...@googlegroups.com
Then the answer is “no, not out-of-the-box”. You might be able to do some parallel programming yourself but whether that works at all depends on the complexity of your problem (i.e., can things be pickled as this is required for multiprocessing). But even then, it’s questionable whether with the all the extra overhead it would be faster in the end than just doing two fits with the different starting values.

Renee

On Jul 29, 2022, at 9:02 AM, 'DARRYNK' via lmfit-py <lmfi...@googlegroups.com> wrote:

Hi Renee,

Matt Newville

unread,
Jul 29, 2022, 9:21:36 AM7/29/22
to lmfit-py
Hi Darrynk, 

Just to clarify what Renee said, the answer to your question is No, there is not a method to run a fit with 2 different starting points.

On Fri, Jul 29, 2022 at 6:03 AM 'DARRYNK' via lmfit-py <lmfi...@googlegroups.com> wrote:
Is there a method that I can fit a model, with 2 different starting points, at the same time and then select the best fit? Obviously I can run one after the other, but this isn't efficient. Can I run a composite model like this? All the documentation for composite models pass in the same parameters.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/lmfit-py/75e7704d-d9c6-444e-aae6-29de440b2b6en%40googlegroups.com.


--Matt 

Laurence Lurio

unread,
Jul 29, 2022, 10:47:20 AM7/29/22
to lmfi...@googlegroups.com
Try the method='differential_evolution' flag.  This samples multiple points over your fit parameter range and evolves a best fit from multiple starting points.  I can make a huge improvement in fits where you tend to get stuck in local minima.  It takes quite a bit longer to run, but can be worth the wait.

Larry

On Fri, Jul 29, 2022 at 6:03 AM 'DARRYNK' via lmfit-py <lmfi...@googlegroups.com> wrote:
Is there a method that I can fit a model, with 2 different starting points, at the same time and then select the best fit? Obviously I can run one after the other, but this isn't efficient. Can I run a composite model like this? All the documentation for composite models pass in the same parameters.

--
Reply all
Reply to author
Forward
0 new messages