Parameter fitting in parameter space with 'holes'

28 views
Skip to first unread message

Levente Balogh

unread,
Mar 21, 2024, 7:56:59 AMMar 21
to lmfit-py
Dear All,

I am working on a model fitting where I want to consider intervals between the lower and upper bounds, specifying regions where the fitter should not search for solutions. For example:

fit_params = lmfit.create_params(alp1_fit={'value': 0.1, 'max': 15, 'min': -15})

Intervals_not_included: [3, 4] and [8, 9]

I have searched everywhere but couldn't find a solution. I'm wondering if it's even possible to fit it this way?

Any information is appreciated.

Kind regards,
Levi

Jonathan Gutow

unread,
Mar 21, 2024, 8:26:45 AMMar 21
to lmfi...@googlegroups.com
If you mean you want to skip points in the middle of your data set try the fit_pandas_GUI in jupyter_pandas_GUI: https://jupyterphysscilab.github.io/jupyter_Pandas_GUI/Pandas_GUI_Doc_Home.html. It will generate fitting code for you. Once you have that you can tweak it to your liking. 

NB. I am the primary author of these GUI tools.

Dr. Jonathan Gutow
Halsey Science Room 412
Chemistry Department
UW Oshkosh
web: https://cms.gutow.uwosh.edu/Gutow
e-mail: gu...@uwosh.edu
Ph: 920-424-1326

On Mar 21, 2024, at 6:51 AM, Levente Balogh <levi.b...@gmail.com> wrote:


CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.


--
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/2a40858e-ceda-4101-9dbb-5887b6d7baf7n%40googlegroups.com.

Levente Balogh

unread,
Mar 21, 2024, 11:55:19 AMMar 21
to lmfi...@googlegroups.com
I would like to omit parts not in the data series, but in the model parameter space.
 Let's say I fit a curve y = a*x^2+bx to a measured x,y data series.
 I know that the lower and upper border of the parameter 'a' [-10,10]. However, within this interval, the value of 'a' cannot be between [1,3] and [5,6].

You received this message because you are subscribed to a topic in the Google Groups "lmfit-py" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lmfit-py/hGrspd7QobQ/unsubscribe.
To unsubscribe from this group and all its topics, 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/68FF9D51-778D-4955-BC23-F79C771B319D%40uwosh.edu.

Jonathan Gutow

unread,
Mar 21, 2024, 12:05:31 PMMar 21
to lmfi...@googlegroups.com
I think you will need to consider creating your own function model. See this part of the FAQs: https://lmfit.github.io/lmfit-py/faq.html#can-parameters-be-used-for-array-indices-or-discrete-values


Dr. Jonathan Gutow
Halsey Science Room 412
Chemistry Department
UW Oshkosh
web: https://cms.gutow.uwosh.edu/Gutow
e-mail: gu...@uwosh.edu
Ph: 920-424-1326

Matt Newville

unread,
Mar 21, 2024, 10:32:51 PMMar 21
to lmfi...@googlegroups.com
Hi Levi,

That seems like a pretty tricky problem.  You might be able to do it by remapping a "continuously-values variable" to the "two-valid-region of values".   This is essentially how lmfit places bounds on parameters (see https://lmfit.github.io/lmfit-py/bounds.html).  Off-hand, I cannot think of a function to do that.

But also: really? Do you mean to say that the value for some variable is between [-10, 10] but cannot be between [1, 3] or [5, 6]?  Is the model mathematically invalid for a value of 2.99 or 5.01?  

You could certainly add a large penalty to your fit for some values of a parameter: that would not necessarily forbid the values outside the bounds, but it would "strongly discourage them".   


--
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/2a40858e-ceda-4101-9dbb-5887b6d7baf7n%40googlegroups.com.


--
--Matt Newville <newville at cars.uchicago.edu630-327-7411
Reply all
Reply to author
Forward
0 new messages