fitting data to a numerical integral
sleepingawake86
I have data that is modeled by a function that involves an integral with no closed form, i.e.
f(x)=\int_0^\infty a(x,t)b(t)dt
there are a few parameters in a(x,t) and b(t) that I want to find by fitting data, but I don't know how to get igor to fit to a function that requires numerical integration. I have done a lot with fitting to user defined functions that are of a closed form, but have not done any igor fitting with numerical functions.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
August 28, 2012 at 12:01 pm - Permalink
can you elaborate on this? I've never used the Integrate 1D before so not sure exactly what you mean.
August 28, 2012 at 10:23 pm - Permalink
DisplayHelpTopic "Integrating a User Function"
The examples will show you the basic use of Integrate1D. The point I was making is that if your integrand has variable coefficients:
a(x,t;a,b,c)
and you are integrating with respect to t, then the only variable that can be passed to the integrand function is t. So you would write a function something like:
Variable tt
NVAR a, b, c, xx
return <some expression containing a, b, c, xx and tt>
end
In order to use the function, you will also need to create the global variables a,b,c and xx. You might do that inside the fit function:
Wave w
Variable inx
Variable/G a = w[0]
Variable/G b = w[1]
Variable/G c = w[2]
Variable/G xx = inx
return Integrate1D(aIntegrand, 0, somethinglarge, options)
end
I have left some pretty important details for you to figure out, like what "somethinglarge" should be. Hopefully your integrand is well-behaved and approaches zero at large t. It is really tough to do a numerical integration truly to infinity!
DO NOT try to write the fitting function and do a fit until you have tested the integrand function, and the use of Integrate1D outside of fitting. Going straight to fitting introduces too many layers of new stuff to debug all at the same time.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
August 29, 2012 at 09:28 am - Permalink
This is also something I wanted to do, and posted about a few months back (http://www.igorexchange.com/node/2868). I didn't have time to play around with it too much back then, so went for a simpler, less effective approach using MATLAB. Did you get any code working that does this? If so I would be interested to see how you got it working. Igor and John were a great help, but it still seemed beyond what I can do in IGOR. When I get some more time I will revisit this problem though.
Thanks
September 6, 2012 at 11:10 pm - Permalink