# [SciPy-User] Global Curve Fitting of 2 functions to 2 sets of data-curves

Charles R Harris charlesr.harris@gmail....
Thu Jun 10 20:28:47 CDT 2010

```On Thu, Jun 10, 2010 at 12:27 PM, <josef.pktd@gmail.com> wrote:

> On Thu, Jun 10, 2010 at 4:05 AM, Sebastian Haase <seb.haase@gmail.com>
> wrote:
> > Hi,
> >
> > so far I have been using scipy.optimize.leastsq to satisfy all my
> > curve fitting needs.
> > But now I am thinking about "global fitting" - i.e. fitting multiple
> > dataset with shared parameters
> > (e.g. ref here:
> >
> http://www.originlab.com/index.aspx?go=Products/Origin/DataAnalysis/CurveFitting/GlobalFitting
> )
> >
> > I have looked here (http://www.scipy.org/Cookbook/FittingData) and here
> > (http://docs.scipy.org/doc/scipy/reference/optimize.html)
> >
> > Can someone provide an example  ? Which of the routines of
> > scipy.optimize are "easiest" to use ?
> >
> > Finally, I'm thinking about a "much more" complicated fitting task:
> > fitting two sets of datasets with two types of functions.
> > In total I have 10 datasets to be fit with a function f1, and 10 more
> > to be fit with function f2. Each function depends on 6 parameters
> > A1,A2,A3, r1,r2,r3.
> > A1,A2,A3 should be identical ("shared") between all 20 sets, while
> > r1,r2,r3 should be shared between the i-th set of type f1 and the i-th
> > set of f2.
> > Last but not least it would be nice if one could specify constrains
> > such that r1,r2,r3 >0 and A1+A2+A3 == 1 and 0<=Ai<=1.
> >
> > ;-)  Is this too much ?
> >
> > Thanks for any help or hints,
>
> Assuming your noise or error terms are uncorrelated, I would still use
> optimize.leastsq or optimize.curve_fit using a function that stacks
> all the errors in one 1-d array. If there are differences in the noise
> variance, then weights/sigma per function as in curve_fit can be used.
>
>
Yep, I just did that today for 1024 data sets of ~800 points, sharing 9
parameters and having 7 parameters unique to each data set. I was able to
simply it a bit because I was only interested in the 9 parameters and they
were also the only ones that entered in non-linearly.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100610/3f69bfba/attachment-0001.html
```