Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13396 > unrolled thread

Help: Problems with fitting a list of data with an equation with two parameters

Started bydinodeblasio@gmail.com
First post2013-02-06 06:50 +0000
Last post2013-02-12 08:23 +0000
Articles 4 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Help: Problems with fitting a list of data with an equation with two parameters dinodeblasio@gmail.com - 2013-02-06 06:50 +0000
    Re: Help: Problems with fitting a list of data with an equation with roby <roby.nowak@gmail.com> - 2013-02-07 02:27 +0000
      Re: Help: Problems with fitting a list of data with an equation with dinodeblasio@gmail.com - 2013-02-08 10:10 +0000
        Re: Help: Problems with fitting a list of data with an equation with roby <roby.nowak@gmail.com> - 2013-02-12 08:23 +0000

#13396 — Help: Problems with fitting a list of data with an equation with two parameters

Fromdinodeblasio@gmail.com
Date2013-02-06 06:50 +0000
SubjectHelp: Problems with fitting a list of data with an equation with two parameters
Message-ID<kesug3$jun$1@smc.vnet.net>
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

[toc] | [next] | [standalone]


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

Fromroby <roby.nowak@gmail.com>
Date2013-02-07 02:27 +0000
SubjectRe: Help: Problems with fitting a list of data with an equation with
Message-ID<kev3er$pbi$1@smc.vnet.net>
In reply to#13396
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...@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

[toc] | [prev] | [next] | [standalone]


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

Fromdinodeblasio@gmail.com
Date2013-02-08 10:10 +0000
SubjectRe: Help: Problems with fitting a list of data with an equation with
Message-ID<kf2iuk$3nr$1@smc.vnet.net>
In reply to#13407
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...@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

[toc] | [prev] | [next] | [standalone]


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

Fromroby <roby.nowak@gmail.com>
Date2013-02-12 08:23 +0000
SubjectRe: Help: Problems with fitting a list of data with an equation with
Message-ID<kfcu59$srb$1@smc.vnet.net>
In reply to#13421
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...@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...@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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web