Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*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 1998

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

Search the Archive

Re: Using a function defined by NIntegrate in NonLinearFit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg14530] Re: Using a function defined by NIntegrate in NonLinearFit
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Thu, 29 Oct 1998 04:33:26 -0500
  • Organization: University of Western Australia
  • References: <70rak2$sfm@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Olivier Pelletier wrote:

> my problem is the following:
> I have defined a funtion
> inten[q_,a_,b_,c_]:=NIntegrate[...]
> Now I want to perform a non linear fit using inten[q,a,b,c] as a model.
> The problem is that NIntegrate as HoldAll as an attribute which seems
> to generate a conflict.

Use a test to test that the argument(s) to inten are numeric.  E.g.,

In[1]:= Needs["Statistics`NonlinearFit`"]

Here is the model:

In[2]:= model[(x_)?NumericQ] := 
	Module[{t}, NIntegrate[t^x, {t, 0, 1}]]

Some dummy data:

In[3]:= data = Table[{x, model[x] + Random[Real, {-0.1, 0.1}]}, 
    {x, 0, 5}]; 

Compute the fit:

In[4]:= NonlinearFit[data, a*model[x] + b, x, {{a, 1}, {b, 0}}, 
  ShowProgress -> True]

Display the fit and the data:

In[5]:= ListPlot[data, PlotStyle -> {Hue[1], AbsolutePointSize[3]}, 
   Epilog -> Plot[%, {x, 0, Length[data]}, 
      DisplayFunction -> Identity][[1]]]; 

Cheers,
	Paul

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul at physics.uwa.edu.au  AUSTRALIA                       
http://www.physics.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________


  • Prev by Date: Newton-Raphson Method
  • Next by Date: Logarithmic plot
  • Previous by thread: Using a function defined by NIntegrate in NonLinearFit
  • Next by thread: stats libs/add ons