MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Simultaneous Nonlinear Data Fits

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109075] Re: Simultaneous Nonlinear Data Fits
  • From: dh <dh at metrohm.com>
  • Date: Mon, 12 Apr 2010 06:55:48 -0400 (EDT)
  • References: <hpplc6$m4f$1@smc.vnet.net>

On 10.04.2010 12:53, Dan O'Brien wrote:
> Hello everyone,
>
> A small statement of my problem:  I have 4 data sets consisting of
> spectroscopic data (intensity vs frequency data).  The data contain
> resonant peaks that are fit with the modulus squared of a sum of complex
> functions (one for each peak for a total of 6 peaks) and is such that I
> must use nonlinear fitting algorithms.  Within the four data sets there
> are peaks that should be fit to the same parameters and then there are
> peaks that vary slightly from data set to data set.
>
> The bottom line is this: I am looking for a solution of the form of a
> nonlinear fitting function that is capable of simultaneously fitting
> multiple data sets where some parameters apply to all the data sets and
> others are specific to only one of the data sets.
>
> I have tried fitting each data set independently using the mathematica
> function NonlinearModelFit but the model is such that the
> bestfitparameters can vary wildly from data set to data set.  Using the
> option to constrain leads to computations that never end.  It would be
> best, in my mind, if Mathematica's fitting algorithm was constrained by
> having to minimize the function of the residuals when forced to consider
> all data sets at once.
>
> I am relatively new to mathematica (I have been hacking at it for about
> a year or so) and appreciate any help this group can offer.
>
> Thanks,
>
> -DanO
>

Hi Dan,
you must merge all the different data sets into one. There are different 
possibilities for this, you may e.g. shift the sets that they do not 
overlap or you may introduce an additional dimension.
Here is an example where I fit 2 spectra containing one independent and 
one common Gaussian peak. Note that you need reasonable starting values 
for the fit to succeed.

d1 = Table[Exp[- 0.02 (x - 30)^2], {x, 100}];
d2 = Table[Exp[- 0.02 (x - 70)^2], {x, 100}];
d3 = Table[Exp[- 0.02 (x - 50)^2], {x, 100}];
ones = Table[1, {100}];
xs = Range[100];
data = Join[Transpose[{xs, -ones, d1}], Transpose[{xs, ones, d2}],
    Transpose[{xs, 0 ones, d3}]];
mod1[x_, z_, x0_] := If[z <= 0, Exp[-0.02 (x - x0)^2], 0];
mod2[x_, z_, x0_] := If[z >= 0, Exp[-0.02 (x - x0)^2], 0];
mod3[x_, z_, x0_] := Exp[-0.02 (x - x0)^2];

sol = FindFit[data, mod1[x, z, x1] + mod2[x, z, x2] + mod3[x, z, x3], 
{{x1, 50}, {x2, 50}, {x3, 50}}, {x, z}]

cheers,
Daniel

-- 

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh at metrohm.com>
Internet:<http://www.metrohm.com>



  • Prev by Date: Re: Simultaneous Nonlinear Data Fits
  • Next by Date: Re: if using Mathematica to solve an algebraic problem
  • Previous by thread: Re: Simultaneous Nonlinear Data Fits
  • Next by thread: Re: Simultaneous Nonlinear Data Fits