Thread Subject: fitting data to an integral

Subject: fitting data to an integral

From: B.K. Chen

Date: 10 Mar, 2007 03:54:49

Message: 1 of 6

Hi , all,

    I have a set of data points to be fitted to an equation,but this
equatin contains an integral sign(it's
not analytic). I cannot find any way to fit my data to an
integral equation in Matlab. Does somebody have ideas about this
issue? If yes,please let me know!

Subject: fitting data to an integral

From: John D'Errico

Date: 10 Mar, 2007 04:36:38

Message: 2 of 6

B.K. Chen wrote:
>
>
> Hi , all,
>
> I have a set of data points to be fitted to an equation,but
> this
> equatin contains an integral sign(it's
> not analytic). I cannot find any way to fit my data to an
> integral equation in Matlab. Does somebody have ideas about this
> issue? If yes,please let me know!
  

A lot depends on the equation itself
and what is under the integral. Many
integrals exist as special functions.
(erf, elliptic functions, incomplete
beta function, etc.) Don't be put off
by my response. MANY people post
exactly this question when their
integrand is as simple as exp(-x^2).
They simply have not looked very hard
for the answer.

If their really is no solution available
in the form of a special function, then
quad is an option, called from within
your objective function. Or splines
(often coupled with regularization)
can be used when no explicit form is
known.

So without any knowledge of your
problem, I cannot suggest how to
solve it.

John

Subject: fitting data to an integral

From: B.K. Chen

Date: 10 Mar, 2007 05:04:12

Message: 3 of 6

Hi, John,

  My equation is show below:

integral sign { [G/(x^2+G^2)] * exp[-(G-a)^2/2b^2] } dG

 integration range is from G=0 to G=infinity

 the coefficients to be determined is a & b

This equation is a integral of product of a Lorenz & a Gaussian.

Subject: fitting data to an integral

From: John D'Errico

Date: 10 Mar, 2007 06:03:09

Message: 4 of 6

B.K. Chen wrote:
>
>
> Hi, John,
>
> My equation is show below:
>
> integral sign { [G/(x^2+G^2)] * exp[-(G-a)^2/2b^2] } dG
>
> integration range is from G=0 to G=infinity
>
> the coefficients to be determined is a & b
>
> This equation is a integral of product of a Lorenz & a Gaussian.
  
So you have data where the integral
is given as a function of x?

As long as a/b>=10 or so, I'd try a
Gauss-Hermite numerical quadrature
inside the objective function. Then
any optimizer will be fine. For
smaller values of a/b, I'd just use
quad over a finite set of limits,
base the upper limit on the value
of a/b.

John

Subject: fitting data to an integral

From: B.K. Chen

Date: 10 Mar, 2007 06:25:12

Message: 5 of 6

> So you have data where the integral
> is given as a function of x?

Yeah~ It's a function of x. My data points are (x, f(x) )

> As long as a/b>=10 or so, I'd try a
> Gauss-Hermite numerical quadrature
> inside the objective function. Then
> any optimizer will be fine. For
> smaller values of a/b, I'd just use
> quad over a finite set of limits,
> base the upper limit on the value
> of a/b.

In cftool(Create Custom Equation --> General Equations ),
 it seems that we cannot input quadl directly , does it?

B.K.

Subject: fitting data to an integral

From: John D'Errico

Date: 10 Mar, 2007 07:10:35

Message: 6 of 6

B.K. Chen wrote:
>
>
>> So you have data where the integral
>> is given as a function of x?
>
> Yeah~ It's a function of x. My data points are (x, f(x) )
>
>> As long as a/b>=10 or so, I'd try a
>> Gauss-Hermite numerical quadrature
>> inside the objective function. Then
>> any optimizer will be fine. For
>> smaller values of a/b, I'd just use
>> quad over a finite set of limits,
>> base the upper limit on the value
>> of a/b.
>
> In cftool(Create Custom Equation --> General Equations ),
> it seems that we cannot input quadl directly , does it?
>
> B.K.
  
I always thought I should learn to use
that toolbox. But I wrote my own little
gui tool for nonlinear regressions long
before it existed, so my incentive was
always pretty low. ;-)

You should be able to supply your own
function as an option. Have it call
quadl. BUT BEWARE!!!!

Do not try to integrate 0 to inf.
Furthermore, use of any adaptive
quadrature on an integrand that
involves a gaussian term and where
you cannot control the gaussian
parameters will likely cause serious
problems, culminating in a secondary
request to this newsgroup.

If you use a set of fixed integration
limits, the optimizer can pass in
any set of parameters (a,b) that it
"desires". If b is very small, the
Gaussian part of the kernel becomes
an effective Dirac delta, which the
numerical integration will fail to
"see".

This is why I suggested use of a
Gauss-Hermite for large a/b. Only
use quadl for the alternative case,
and use a carefully chosen upper
limit on the integration. You can
find a nice tool for this purpose
on the FEX:

 <http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=32&objectType=file>

John

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com