# exp regression?

Discussion in 'Java' started by jackson marshmallow, Jul 17, 2003.

1. ### jackson marshmallowGuest

Hello everyone,

Is there a free Java implementation of an exponential regression algorithm
(i.e. to generate exponential regression function coefficients for f(x) =
A*exp(B*x)+C)?

The excellent JSci package has linear and polinominal regressions, but not
exponential...

If there is not, I will need to write one... Any advice will be
appreciated...

jackson marshmallow, Jul 17, 2003

2. ### Jos A. HorsmeierGuest

"jackson marshmallow" <> wrote in message news:17uRa.1485\$...
> Hello everyone,
>
> Is there a free Java implementation of an exponential regression algorithm
> (i.e. to generate exponential regression function coefficients for f(x) =
> A*exp(B*x)+C)?
>
> The excellent JSci package has linear and polinominal regressions, but not
> exponential...
>
> If there is not, I will need to write one... Any advice will be
> appreciated...

If you get rid of the horizontal asymptote C (by inspecting the data
samples and finding an approximate value C'), your equation yields:

f'(x) [= f(x)-C'] = A*exp(B*x)

taking the logarithm on both sides reduces your problem to linear
regression again.

kind regards,

Jos

Jos A. Horsmeier, Jul 17, 2003

3. ### jackson marshmallowGuest

"Jos A. Horsmeier" <> wrote in message
news:3f16993a\$0\$45374\$...
> "jackson marshmallow" <> wrote in message

news:17uRa.1485\$...
> > Hello everyone,
> >
> > Is there a free Java implementation of an exponential regression

algorithm
> > (i.e. to generate exponential regression function coefficients for f(x)

=
> > A*exp(B*x)+C)?
> >
> > The excellent JSci package has linear and polinominal regressions, but

not
> > exponential...
> >
> > If there is not, I will need to write one... Any advice will be
> > appreciated...

>
> If you get rid of the horizontal asymptote C (by inspecting the data
> samples and finding an approximate value C'), your equation yields:
>
> f'(x) [= f(x)-C'] = A*exp(B*x)
>
> taking the logarithm on both sides reduces your problem to linear
> regression again.
>
> kind regards,
>
> Jos
>

That will yield wrong results.

jackson marshmallow, Jul 17, 2003
4. ### jackson marshmallowGuest

"jackson marshmallow" <> wrote in message
newsuBRa.1579\$...
>
> "Jos A. Horsmeier" <> wrote in message
> news:3f16993a\$0\$45374\$...
> > "jackson marshmallow" <> wrote in message

> news:17uRa.1485\$...
> > > Hello everyone,
> > >
> > > Is there a free Java implementation of an exponential regression

> algorithm
> > > (i.e. to generate exponential regression function coefficients for

f(x)
> =
> > > A*exp(B*x)+C)?
> > >
> > > The excellent JSci package has linear and polinominal regressions, but

> not
> > > exponential...
> > >
> > > If there is not, I will need to write one... Any advice will be
> > > appreciated...

> >
> > If you get rid of the horizontal asymptote C (by inspecting the data
> > samples and finding an approximate value C'), your equation yields:
> >
> > f'(x) [= f(x)-C'] = A*exp(B*x)
> >
> > taking the logarithm on both sides reduces your problem to linear
> > regression again.
> >
> > kind regards,
> >
> > Jos
> >

>
> That will yield wrong results.
>

PS Sorry Jos, I was in a rush and didn't mean to be rude... I do appreciate

Basically, I have been doing something like what you are describing, which
was better than nothing and was easy to code. But what's needed a true
exponential fit.

I also posted this question to sci.math etc.

jackson marshmallow, Jul 18, 2003
5. ### Jos A. HorsmeierGuest

"jackson marshmallow" <> wrote in message newsCMRa.136\$...
>
> "jackson marshmallow" <> wrote in message
> newsuBRa.1579\$...
> >
> > "Jos A. Horsmeier" <> wrote in message
> > news:3f16993a\$0\$45374\$...
> > > "jackson marshmallow" <> wrote in message

> > news:17uRa.1485\$...
> > > > Hello everyone,
> > > >
> > > > Is there a free Java implementation of an exponential regression

> > algorithm
> > > > (i.e. to generate exponential regression function coefficients for

> f(x)
> > =
> > > > A*exp(B*x)+C)?
> > > >
> > > > The excellent JSci package has linear and polinominal regressions, but

> > not
> > > > exponential...
> > > >
> > > > If there is not, I will need to write one... Any advice will be
> > > > appreciated...
> > >
> > > If you get rid of the horizontal asymptote C (by inspecting the data
> > > samples and finding an approximate value C'), your equation yields:
> > >
> > > f'(x) [= f(x)-C'] = A*exp(B*x)
> > >
> > > taking the logarithm on both sides reduces your problem to linear
> > > regression again.
> > >
> > > kind regards,
> > >
> > > Jos
> > >

> >
> > That will yield wrong results.
> >

>
> PS Sorry Jos, I was in a rush and didn't mean to be rude... I do appreciate

I didn't consider it rude; a bit concise though ;-) But you're right, if
your estimate for the horizontal asymptote C' is way off, the results will
be way off also ...

> Basically, I have been doing something like what you are describing, which
> was better than nothing and was easy to code. But what's needed a true
> exponential fit.

If your sample set is large *and* if the condition number of the resulting
matrix is low (i.e. the fit will be 'fine') a better estimate can be
made for C by elliminating it all together; have a look:

f(x) = A*exp(B*x)+C
f'(x) = A*B*exp(B*x)

(where f'(x) is the derivative of f(x) w.r.t. x)

given your sample value set (x_0, y_0) ... (x_i, y_i) ... (x_n, y_n),
the derivative values can be estimated as follows:

f'(x_i) = (y_i+1-y_i)/(x_i+1-x_i)

The value for C can be estimated then by taking the average of all
the C'_i values from your sample set.

kind regards,

Jos

Jos A. Horsmeier, Jul 19, 2003