Re: Re: Fitting parameters of nonlinear diff equation system

• To: mathgroup at smc.vnet.net
• Subject: [mg81505] Re: [mg81303] Re: Fitting parameters of nonlinear diff equation system
• From: "Szabolcs Horvát" <szhorvat at gmail.com>
• Date: Wed, 26 Sep 2007 06:39:52 -0400 (EDT)
• References: <fcnl8h\$s85\$1@smc.vnet.net> <200709181002.GAA04068@smc.vnet.net>

```Hi Paul,

I am writing to warn you that something *might* have gone wrong with
the calculations.  (Let's hope that it is just a misunderstanding).

On 24/09/2007, Paul Thomas <paul.pgt at gmail.com> wrote:
> Hi everyone,
>
> Just wanted to follow up with this. The e-mail below from Szabolcs was very
> helpful and it did work, with just a minor syntax change. He suggested the
> following code for fitting a system of differential equations with multiple
> parameters:
>
> fun[a_, b_, c_] :=
>    First[
>      f /. NDSolve[
>             deq /. {b1 -> a, h -> b, r -> c},
>             {v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, f},
>             {t, 0, 10} (* dummy values *)
>           ]]
>
> opt[a_?NumericQ, b_?NumericQ, c_?NumericQ] :=
>    Norm[fun[a, b, c] /@ tvals - fvals]
>
> Now use FindMinimum on 'opt', like this:
>
> FindMinimum[opt[a,b,c], {{a,1.}, {b,2.}, {c,3.}}]
>
> One change I had to make was in the "fun[a_,b_,c_]" equation--instead of
> "f/.NDSolve" it should be "f[t]/.NDSolve" etc etc.

While I admit that I did not test these commands thoroughly (as I did
not have access to the data), something seems to be wrong with these
modifications.  I meant fun[] to return a function, not a number (note
that we later map this function to a list) ... if f is changed to
f[t], then the return value will not be a function.

> The other change I had to make was in the opt equation. I just needed to put
> parentheses around the "(fun[a, b, c] /@ tvals)" term--otherwise it thinks
> the "/@" Map command is being applied to tvals-fvals.

Something seems to be wrong here too, as /@ has a higher precedence than - .

Example:

In[1]:=
a={1,2,3};
b={4,5,6};

In[3]:= f/@a-b
Out[3]= {-4+f[1],-5+f[2],-6+f[3]}

> I want to thank everyone for their comments, I'm so pleased with this
> technique now. I think it works very much like the documentation says
> FindFit works, but it is much more flexible in terms of the data you can
> input for the fit and also allows a whole system to be solved with data only
> from a single equation. To me, those are both huge advantages. Thanks!
>
> Paul

Szabolcs

```

• Prev by Date: Re: Is RealTime3D back?
• Next by Date: Re: Re: Fitting parameters of nonlinear diff equation system
• Previous by thread: Re: Fitting parameters of nonlinear diff equation system
• Next by thread: Re: Re: Fitting parameters of nonlinear diff equation system