Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

Re: Help: Problems with fitting a list of data with an equation with

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129767] Re: Help: Problems with fitting a list of data with an equation with
  • From: roby <roby.nowak at gmail.com>
  • Date: Tue, 12 Feb 2013 03:23:22 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <kesug3$jun$1@smc.vnet.net> <kev3er$pbi$1@smc.vnet.net> <kf2iuk$3nr$1@smc.vnet.net>

Hi Dino

In[9]:= y /. model /. {A -> 1, B -> 1, b -> 1, t -> 0}

Out[9]= -I


As I posted before you must choose a modell which gives you real values for the complete parameter range.

Attention your data is called data2211 and not data 1211

"A", and "B" are paramters but what with "b"

As you can see your modell evaluates to -i for e.g. the paramtere set:
{A -> 1, B -> 1, b -> 1, t -> 0}
which of course is not real.

The reasson is that you are using square roots in your modell wich evaluate as imaginary or complex for negative input parameters.

Think about completely changing your modell.



What about this solution:


model = a2 t^2 + a3 t^3 + a4 t^4 + b Erf[((t - x0)/c)];
ff = FindFit[data2211, model , {a2, a3, a4, b, c, x0}, t];

Plot[model /. ff, {t, 0, 70}, Epilog -> Point@data2211, 
 PlotLabel -> Column@ff]



Am Freitag, 8. Februar 2013 11:10:28 UTC+1 schrieb dinode... at gmail.com:
> Hello Robert,
> 
> 
> 
> thanks for the help, however still I have some error coming from my fitting, I tried:
> 
> Clear[y];
> 
> Column[{model =
> 
>     Solve[-A/(2 Sqrt[
> 
>               B^2 + 4 A B]) (Log[(2 A y^2 + b -
> 
>                Sqrt[B^2 + 4 A B])/(2 A y^2 + b +
> 
>                Sqrt[B^2 + 4 A B])]) -
> 
>          A/(2 Sqrt[
> 
>               B^2 + 4 A B]) (Log[(b - Sqrt[B^2 + 4 A B])/(b +
> 
>                Sqrt[B^2 + 4 A B])]) == t, y][[1]] // FullSimplify,
> 
>    param = FindFit[data1211, y[t] /. model, {A, B}, t],
> 
>    Plot[y[t] /. model /. param, {t, 0, Max[data1211[[All, 1]]]},
> 
>     PlotRange -> All, ImageSize -> 350, PlotStyle -> {Black},
> 
>     AxesLabel -> {"", "Ca,mol/liter"}, BaseStyle -> {FontSize -> 15},
> 
>     Epilog -> {Text["Step [1]", {50, 0.00002}],
> 
>       Text["(sec)", {140, 0.00002}], Point[data1211]}]}] // Quiet
> 
> 
> 
> and gave me some errors.
> 
> 
> 
> what it could be?
> 
> Thanks again,
> 
> 
> 
> Dino
> 
> 
> 
> 
> 
> Il giorno gioved=EC 7 febbraio 2013 04:27:39 UTC+2, roby ha scritto:
> 
> > Hi Dino,
> 
> >
> 
> >
> 
> >
> 
> > As a first hint:
> 
> >
> 
> >
> 
> >
> 
> > model = Solve[-A/(2 Sqrt[
> 
> >
> 
> >            B^2 + 4 A B]) (Log[(2 A y^2 + b -
> 
> >
> 
> >             Sqrt[B^2 + 4 A B])/(2 A y^2 + b + Sqrt[B^2 + 4 A B])]) -
> 
> >
> 
> >       A/(2 Sqrt[
> 
> >
> 
> >            B^2 + 4 A B]) (Log[(b - Sqrt[B^2 + 4 A B])/(b +
> 
> >
> 
> >             Sqrt[B^2 + 4 A B])]) == t, y][[1]] // FullSimplify
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > you can't youse {} as instead of () for groupung of expressions.
> 
> >
> 
> >
> 
> >
> 
> > {} in Mathematica is used for arrays.
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > Further you must ensure that you choose a realvalued modell (not complex) before trying to fit.
> 
> >
> 
> >
> 
> >
> 
> > Regards Robert
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > Am Mittwoch, 6. Februar 2013 07:50:43 UTC+1 schrieb dinode... at gmail.com:
> 
> >
> 
> > > Hello everyone:
> 
> >
> 
> > >
> 
> >
> 
> > > I'd like to fit a list like:
> 
> >
> 
> > >
> 
> >
> 
> > > data2211={{0., 0.}, {1., 0.0000202672}, {2., 0.0000606506}, {3.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.0000902571}, {4., 0.00011201}, {5., 0.000122325}, {6.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000129026}, {7., 0.000136861}, {8., 0.000138904}, {9.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000142179}, {10., 0.000145617}, {11., 0.000150792}, {12.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000153723}, {13., 0.000158662}, {14., 0.000163744}, {15.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000170338}, {16., 0.000176373}, {17., 0.000184436}, {18.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000191055}, {19., 0.000197175}, {20., 0.000205177}, {21.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000212824}, {22., 0.000221142}, {23., 0.000228844}, {24.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000236553}, {25., 0.000243398}, {26., 0.000251118}, {27.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000258642}, {28., 0.00026638}, {29., 0.000275992}, {30.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000284433}, {31., 0.000291682}, {32., 0.000300548}, {33.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000308275}, {34., 0.000316503}, {35., 0.000322813}, {36.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000332034}, {37., 0.000340994}, {38., 0.000349994}, {39.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.00035922}, {40., 0.000366491}, {41., 0.00037264}, {42.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000379767}, {43., 0.000388169}, {44., 0.000395309}, {45.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000403434}, {46., 0.000411034}, {47., 0.00041769}, {48.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000424886}, {49., 0.000431168}, {50., 0.000437785}, {51.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000446171}, {52., 0.000453136}, {53., 0.000460042}, {54.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000467164}, {55., 0.000473857}, {56., 0.00047967}, {57.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.00048695}, {58., 0.000492749}, {59., 0.000499251}, {60.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000506003}, {61., 0.000512512}, {62., 0.000516679}, {63.,
> 
> >
> 
> > >
> 
> >
> 
> > >   0.000522183}};
> 
> >
> 
> > >
> 
> >
> 
> > >
> 
> >
> 
> > >
> 
> >
> 
> > > with something like:
> 
> >
> 
> > >
> 
> >
> 
> > > Clear[y];
> 
> >
> 
> > >
> 
> >
> 
> > > Column[{model =
> 
> >
> 
> > >
> 
> >
> 
> > >     Solve[-A/(
> 
> >
> 
> > >
> 
> >
> 
> > >          2 Sqrt[B^2 + 4 A B]) {Log[(2 A y^2 + b - Sqrt[B^2 + 4 A B])/(
> 
> >
> 
> > >
> 
> >
> 
> > >            2 A y^2 + b + Sqrt[B^2 + 4 A B])]} - -A/(
> 
> >
> 
> > >
> 
> >
> 
> > >          2 Sqrt[B^2 + 4 A B]) {Log[(b - Sqrt[B^2 + 4 A B])/(
> 
> >
> 
> > >
> 
> >
> 
> > >            b + Sqrt[B^2 + 4 A B])]} == t, y[t], t][[1]],
> 
> >
> 
> > >
> 
> >
> 
> > >    param = FindFit[data1211, y[t] /. model, {A, B}, t],
> 
> >
> 
> > >
> 
> >
> 
> > >    Plot[y[t] /. model /. param, {t, 0, Max[data1211[[All, 1]]]},
> 
> >
> 
> > >
> 
> >
> 
> > >     PlotRange -> All}]}] // Quiet
> 
> >
> 
> > >
> 
> >
> 
> > >
> 
> >
> 
> > >
> 
> >
> 
> > > however there is some errors which I can't figure it out.
> 
> >
> 
> > >
> 
> >
> 
> > > Any help is appreciated.
> 
> >
> 
> > >
> 
> >
> 
> > >
> 
> >
> 
> > >
> 
> >
> 
> > > Thanks,
> 
> >
> 
> > >
> 
> >
> 
> > > Dino



  • Prev by Date: 3D plots remain black in front end
  • Next by Date: Factoring a polynomial with many variables
  • Previous by thread: Re: Help: Problems with fitting a list of data with an equation with
  • Next by thread: Problems with version 9.0.1 trial on Windows and Mac