MathGroup Archive 2010

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

Search the Archive

Re: Nonlinear fitting question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111612] Re: Nonlinear fitting question
  • From: "Kevin J. McCann" <Kevin.McCann at umbc.edu>
  • Date: Sat, 7 Aug 2010 01:33:03 -0400 (EDT)
  • References: <i3gpnv$2tn$1@smc.vnet.net>

How about something like this. I assume that "in reality" y2=1-y1, and 
transform the "data" y2, then I just roll my own least squares fit.

Kevin

(*my measurements*)
dat1 = Table[{t, y1[t] + RandomReal[{-1, 1}]/20}, {t, 0, 10, .1}];
dat2 = Table[{t, y2[t] + RandomReal[{-1, 1}]/20}, {t, 0, 10, .1}];
X = dat1[[All, 1]];
Y1 = dat1[[All, 2]];
Y2 = dat2[[All, 2]];
Y = Join[dat1, Transpose[{X, 1 - Y2}]];
ListPlot[Y]
X = dat1[[All, 1]];
Y1 = dat1[[All, 2]];
Y2 = dat2[[All, 2]];
Clear[f, \[Kappa], \[Beta]]
f[\[Kappa]_, \[Beta]_] :=
  Total[((\[Beta] + E^(-\[Kappa] #[[1]]))/(1 + \[Beta]) - #[[2]])^2 & /@
     Y]
FindMinimum[f[\[Kappa], \[Beta]], {\[Kappa], 1}, {\[Beta], 1}]

eric g wrote:
> Hello Group,
> In the example below I want to do a fitting "exploiting" the correlation 
> between y1 and y2 rather than separate them like I did. Like a 2D 
> fitting thing.
> Also, in NonlinearModelFit, I dont like treating 1/(1+b) like another 
> parameter.
> 
> how to do it?
> 
> best regards,
> Eric
> 
> (* my model *)
> b = 1;
> k = 1/2;
> y1[t_] = (b + Exp[-k*t])/(1 + b);
> y2[t_] = (1 - Exp[-k*t])/(1 + b);
> 
> (* my measurements *)
> dat1 = Table[{t, y1[t] + RandomReal[{-1, 1}]/20}, {t, 0, 10, .1}];
> dat2 = Table[{t, y2[t] + RandomReal[{-1, 1}]/20}, {t, 0, 10, .1}];
> 
> Plot[{y1[t], y2[t]}, {t, 0, 10}, Epilog -> {{Red, Point[dat1]}, {Blue, 
> Point[dat2]}},  PlotStyle -> {Red, Blue}]
> 
> (*FITTING*)
> (* results with dat1:   *)
> Clear[b, k];
> Normal[NonlinearModelFit[dat1, (b + Exp[-k*t])/(1 + b), {b, k}, t]]
> 0.504916 (0.980528 + E^(-0.492309 t))
> 
> (* results with dat2:   *)
> Clear[b, k];
> Normal[NonlinearModelFit[dat2, (1 - Exp[-k*t])/(1 + b), {b, k}, t]]
> 0.494348 (1 - E^(-0.524777 t))
> 
> 
> 


  • Prev by Date: Re: BinLists in Array
  • Next by Date: Re: ListPlot with PlotStyle->Dashed causes problems
  • Previous by thread: Nonlinear fitting question
  • Next by thread: ListPlot with PlotStyle->Dashed causes problems