Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: NonlinearRegress and numerical functions...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20219] Re: [mg20132] NonlinearRegress and numerical functions...
  • From: Larske Ragnarsson <loke at ic.chalmers.se>
  • Date: Wed, 6 Oct 1999 21:06:35 -0400
  • Organization: Chalmers University of Technology
  • References: <7t8d2v$gei@smc.vnet.net> <7tcajd$m32@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi again
 Thanks for the help. However as Daniel pointed out, I am trying to use
NonlinearFit/Regress on a function which is rather complex. Since I want
to fit on the parameters which are both involved in the DE AND the integration
I MUST (I think) solve the DE each time. On top of this I must also solve
it numerically since it has no symbolic solutions (which of course would
have trivialized the problem).
 Daniel suggested that I use FindMinimum, and it seems to work (I actually
tried this before) but it is very slow and is often unsuccesful, e.g. this
error message turns up now and then:
 FindMinimum::regex :
     Reached the point 5.5743824908216554`*^23 which
is outside the region {{10^21, 10^25}, {0, 0.2}, {0, 0.2}}.
 which as you can see is quite strange :-) Any suggestions on this matter
are of course welcome and appreciated!
 Problems most often arise when I try to fit on more than two of the
parameters.
 There were also some who mentioned that I would need more data, and
that is true, but since this are real measurements (passivation of defects)
and the measurements take a while to do, this is what I have.  Below
are my actual problem again, with the data and FindMinimum call. Last,
there is a mathematica cell expression!
 Thanks again for any help!!
  
 /Lars-&amp;Aring;ke Ragnarsson
 ----------
    Statistics`NormalDistribution`
    Statistics`NonlinearFit`
  k0[T_,Ef0_]:=1.43 10^-12 E^-(Ef0/8.618 10^-5/T)
  k1[T_,Ef1_]:=1.43 10^-12 E^-(Ef1/8.618 10^-5/T)
  Pb0H2[t_, T_, Ef0_, Ef1_, H20_, Pb00_,  Pb10_] :=
 (Pb0[t] /. (NDSolve[{Pb0'[t] == -k0[T, Ef0] H2[t]Pb0[t], Pb1'[t] ==
-k1[T, Ef1] H2[t]Pb1[t],  H2'[t] == -k0[T, Ef0]/tox; H2[t] Pb0[t]
 - k1[T, Ef1]/tox H2[t] Pb1[t], Pb0[0] == Pb00, Pb1[0] == Pb10, H2[0]
== H20},
 {Pb0[t], Pb1[t], H2[t]}, {t,0,10000}, MaxSteps -> 100000])[[1]])/Pb00
 Pb0H2p[t_, T_, Ef0_, Ef1_, H20_, Pb00_, Pb10_] := Pb0H2[t0, T, Ef0,Ef1,
H20, Pb00, Pb10] /. {t0 -> t}
 Pb0H2DistDouble[t_, T_, Ef0_, sigma0_, Ef1_, sigma1_, H20_, Pb00_, Pb10_]:=
   NIntegrate[(Pb0H2p[t, T, Eff0, Eff1, H20, Pb00, Pb10]* PDF[NormalDistribution[Ef0,
 sigma0], Eff0]*  PDF[NormalDistribution[Ef1,sigma1], Eff1]), {Eff0,
Ef0 - 5sigma0,  Ef0 + 5sigma0}, {Eff1, Ef1 - 5sigma1, Ef1 + 5sigma1}, 
Method -> Trapezoidal, AccuracyGoal -> 2, PrecisionGoal -> 2]
 fittingdata=  {{0, 170, 1.}, {100, 170, 1.0007}, {1000, 170, 0.97656},
{10000, 170,
     0.94368}, {0, 200, 1.}, {100, 200, 0.98866}, {1000,
200, 0.9525}, {10000,
     200, 0.93537}, {0, 230, 1.}, {100, 230, 0.95589},
{1000, 230,
     0.92255}, {10000, 230, 0.91}, {0, 260, 1.}, {100,
260, 0.9215}, {1000,
     260, 0.90957}, {10000, 260, 0.90555}}
 NonlinearRegress trial:
 -----------------------
  NonlinearRegress[fittingdata, Pb0H2DistSingle[t, T, 1.51, 0.14,
1.57, 0.15, H20, 1.4 10^16, 1.1 10^16], {t, T}, {H20,{10^23,10^24},10^21,10^25}]
 ====> plenty of errors
  
 FindMinimum trial:
 -------------------
 Pb0H2DistDoubleFitMS[Ef0_, sigma0_, Ef1_, sigma1_, H20_, Pb00_, Pb10_]
:=
   Plus @@ Apply[(Pb0H2DistDoubleFit[#1, #2, Ef0, sigma0, Ef1,
sigma1, H20, Pb00,
                
Pb10] - #3)^2 &amp;, fittingdata, {1}]
 fit2 =
     FindMinimum[
       Pb0H2DistDoubleFitMS[1.51, sigma0, 1.57,
sigma1, H20, 1.4 10^16,
         1.1 10^16], {H20, {5 10^23,
6 10^23}, 10^21,
         10^25}, {sigma0, {0.1, 0.12},
0, 0.2}, {sigma1, {0.1, 0.12}, 0,
         0.2}, AccuracyGoal -> 50,
MaxIterations -> 1000,
       WorkingPrecision -> 100]
 ====>
 FindMinimum::regex :
     Reached the point 5.5743824908216554`*^23 which
is outside the region {{10^21, 10^25}, {0, 0.2}, {0, 0.2}}.
  
 --------------------------------
 Mathematica  Expression
 --------------------------------
  
 Cell[CellGroupData[{
 Cell["Nonlinearfitting", "Subsection"],
 Cell[BoxData[{
     \(   Statistics`NormalDistribution`\), "\[IndentingNewLine]",
     \(   Statistics`NonlinearFit`\)}], "Input"],
 Cell[BoxData[{
     \(k0[T_, Ef0_] :=
       1.43\ 10^\(-12\)\ E^\(-\((Ef0/8.618\
10^\(-5\)/
                  
T)\)\)\), "\[IndentingNewLine]",
     \(k1[T_, Ef1_] :=
       1.43\ 10^\(-12\)\ E^\(-\((Ef1/8.618\
10^\(-5\)/T)\)\)\)}], "Input"],
 Cell[BoxData[{
     \(Pb0H2[t_, T_, Ef0_, Ef1_, H20_, Pb00_,
         Pb10_] := \((Pb0[
              
t] /. \((NDSolve[{\(Pb0'\)[t] == \(-k0[T, Ef0]\)\ H2[t]
                        
Pb0[t], \(Pb1'\)[t] == \(-k1[T, Ef1]\)\ H2[t]
                        
Pb1[t], \(H2'\)[t] == \(-k0[T, Ef0]\)/tox; \
                    
H2[t]\ Pb0[t] - k1[T, Ef1]/tox\ H2[t]\ Pb1[t],
                    
Pb0[0] == Pb00, Pb1[0] == Pb10, H2[0] == H20}, {Pb0[t],
                    
Pb1[t], H2[t]}, {t, 0, 10000},
                  
MaxSteps -> 100000])\)[\([1]\)])\)/
         Pb00\), "\[IndentingNewLine]",
     \(Pb0H2p[t_, T_, Ef0_, Ef1_, H20_, Pb00_, Pb10_]
:=
       Pb0H2[t0, T, Ef0, Ef1, H20, Pb00, Pb10]
/. {t0 -> t}\)}], "Input"],
 Cell[BoxData[
     \(Pb0H2DistDouble[t_, T_, Ef0_, sigma0_, Ef1_, sigma1_,
H20_, Pb00_,
         Pb10_] := NIntegrate[\((Pb0H2p[t,
T, Eff0, Eff1, H20, Pb00, Pb10]*
            
PDF[NormalDistribution[Ef0, sigma0], Eff0]*
            
PDF[NormalDistribution[Ef1, sigma1], Eff1])\), {Eff0,
           Ef0 - 5 
sigma0, Ef0 + 5  sigma0}, {Eff1, Ef1 - 5  sigma1,
           Ef1 + 5 
sigma1}, Method -> Trapezoidal, AccuracyGoal -> 2,
         PrecisionGoal -> 2]\)],
"Input"],
 Cell[BoxData[
     \(fittingdata = {{0, 170, 1. }, {100, 170, 1.0007},
{1000, 170,
           0.97656}, {10000,
170, 0.94368}, {0, 200, 1. }, {100, 200,
           0.98866}, {1000,
200, 0.9525}, {10000, 200, 0.93537}, {0, 230,
           1. }, {100,
230, 0.95589}, {1000, 230, 0.92255}, {10000, 230,
           0.91}, {0, 260,
1. }, {100, 260, 0.9215}, {1000, 260,
           0.90957}, {10000,
260, 0.90555}}\)], "Input"],
 Cell[BoxData[
     \(NonlinearRegress[fittingdata,
       Pb0H2DistSingle[t, T, 1.51, 0.14, 1.57,
0.15, H20, 1.4\ 10^16,
         1.1\ 10^16], {t, T}, {H20,
{10^23, 10^24}, 10^21,
         10^25}]\)], "Input"],
 Cell[BoxData[{
     \(Pb0H2DistDoubleFitMS[Ef0_, sigma0_, Ef1_, sigma1_,
H20_, Pb00_, Pb10_] :=
       Plus @@ Apply[\((Pb0H2DistDoubleFit[#1,
#2, Ef0, sigma0, Ef1, sigma1,
                    
H20, Pb00, Pb10] - #3)\)^2 &amp;,
           fittingdata,
{1}]\), "\[IndentingNewLine]",
     \(fit2 =
       FindMinimum[
         Pb0H2DistDoubleFitMS[1.51,
sigma0, 1.57, sigma1, H20, 1.4\ 10^16,
           1.1\ 10^16],
{H20, {5\ 10^23, 6\ 10^23}, 10^21,
           10^25}, {sigma0,
{0.1, 0.12}, 0, 0.2}, {sigma1, {0.1, 0.12}, 0,
           0.2}, AccuracyGoal
-> 50, MaxIterations -> 1000,
         WorkingPrecision -> 100]\)}],
"Input"]
 }, Open  ]]


  • Prev by Date: Re: V4.0 on NT4.0/SP3 does not update the Start/Documents List
  • Next by Date: Re: adjusting frame size in plot
  • Previous by thread: Re: NonlinearRegress and numerical functions...
  • Next by thread: Re: NonlinearRegress and numerical functions...