Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

FindFit with constraints is slow

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89207] FindFit with constraints is slow
  • From: Matt.Latourette at rad.msu.edu
  • Date: Thu, 29 May 2008 07:04:49 -0400 (EDT)

I'm using FindFit to fit the parameters of an exponential decay.  I'd
like to include constraints to force the output parameters to be non-
negative since negative values do not make any sense in the real world
situation being modeled.  The FindFit operation occurs within a
function that is called many times.  However, when I do this the total
computation time increases drastically (by 3 orders of magnitude).
Any thoughts on why the version with constraints is so incredibly
slow?

The original code:
FindFit[OrderedPairList, \
Global`M0*Exp[-Global`R2Star*t], {{Global`M0, initM0}, \
{Global`R2Star, initR2Star}}, {t}, MaxIterations->500, \
Method->Automatic, \
AccuracyGoal->3, PrecisionGoal->3, \
WorkingPrecision->MachinePrecision]

The code with constraints:
FindFit[OrderedPairList, \
{Global`M0*Exp[-Global`R2Star*t], Global`R2Star>=0, \
Global`M0>=0}, \
{{Global`M0, initM0}, {Global`R2Star, initR2Star}}, \
{t}, MaxIterations->500, Method->Automatic, \
AccuracyGoal->3, PrecisionGoal->3, \
WorkingPrecision->MachinePrecision]


where OrderedPairList represents data of the form {{x1, y1}, {x2,
y2}, ... {xn, yn}} where the x's and y's are floats and initM0 and
initR2Star are real-valued constants.


  • Prev by Date: Re: Plot3D crashes Mathematica 6.02
  • Next by Date: Re: simplify polynomial
  • Previous by thread: Re: NDSolve with arrays
  • Next by thread: FindRoot with vector domain