Problem fitting a curve



 Science > Physics > Problem fitting a curve

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: Science > Physics
User: "proton"
Date: 03 Mar 2005 02:45:12 AM
Object: Problem fitting a curve
I have to fit the following points using the given equation:
points x(n): 0.39, 0.72, 1.00, 1.52, 2.8, 5.2, 9.54, 19.2, 30.1
equation: a/x^2 + b/x + c log(x) = n*K, where n is an integer
I have to find the best approximate values for the constants a, b, c,
K.
The problem is that the values of n are ANY integer, so instead of
being n= 0, 1, 2, ... it could be n=-19, -18, -17, ...
I need help to: 1. find the best fit for this equation and these values
(at least for a simple case, such as n= 0, 1, 2...) and 2. see if there
is a general way of tackling this kind of problem, when the sequence
for n does not have any constraints.
Any help will be very much appreciated.
.

User: "Rod"

Title: Re: Problem fitting a curve 03 Mar 2005 04:57:26 AM
For a function and data set like this I would use maximum likelihood not
least squares.
I would first treat n as a real number to convince myself it is not
something very large.
that done I would simply systematically try all the possibilities in the
neighbourhood of the real value of n.
With such a small data set this should be easy. Graphing the result will
tell you if you are off the mark.
"proton" <leosarasua@gmail.com> wrote in message
news:1109839512.606742.109180@z14g2000cwz.googlegroups.com...

I have to fit the following points using the given equation:

points x(n): 0.39, 0.72, 1.00, 1.52, 2.8, 5.2, 9.54, 19.2, 30.1

equation: a/x^2 + b/x + c log(x) = n*K, where n is an integer


I have to find the best approximate values for the constants a, b, c,
K.

The problem is that the values of n are ANY integer, so instead of
being n= 0, 1, 2, ... it could be n=-19, -18, -17, ...

I need help to: 1. find the best fit for this equation and these values
(at least for a simple case, such as n= 0, 1, 2...) and 2. see if there
is a general way of tackling this kind of problem, when the sequence
for n does not have any constraints.

Any help will be very much appreciated.

.

User: "Maarten van Reeuwijk"

Title: Re: Problem fitting a curve 03 Mar 2005 04:12:08 AM
Look up least-squares fitting & regression analysis:
http://mathworld.wolfram.com/LeastSquaresFitting.html
HTH, Maarten
--
===================================================================
Maarten van Reeuwijk Thermal and Fluids Sciences
Phd student dept. of Multiscale Physics
www.ws.tn.tudelft.nl Delft University of Technology
.

User: "John C. Polasek"

Title: Re: Problem fitting a curve 03 Mar 2005 12:12:54 PM
On 3 Mar 2005 00:45:12 -0800, "proton" <leosarasua@gmail.com> wrote:

I have to fit the following points using the given equation:

points x(n): 0.39, 0.72, 1.00, 1.52, 2.8, 5.2, 9.54, 19.2, 30.1

equation: a/x^2 + b/x + c log(x) = n*K, where n is an integer


I have to find the best approximate values for the constants a, b, c,
K.

The problem is that the values of n are ANY integer, so instead of
being n= 0, 1, 2, ... it could be n=-19, -18, -17, ...

I need help to: 1. find the best fit for this equation and these values
(at least for a simple case, such as n= 0, 1, 2...) and 2. see if there
is a general way of tackling this kind of problem, when the sequence
for n does not have any constraints.

Any help will be very much appreciated.

You have a mongrel equation with that log in there. You could do
yourself some good with change of variable y = 1/x to get the more
attractive
ay2 + by -clogy = nK
then logy = (ay2 + by -nK)/c
so logy = a'y2 + b'y - n'K
the primes after dividing thru by c to reduce to fewer paramters
Mr. Dual Space
If you have something to say, write an equation.
If you have nothing to say, write an essay
.

User: "tadchem"

Title: Re: Problem fitting a curve 03 Mar 2005 08:43:28 AM
proton wrote:

I have to fit the following points using the given equation:

points x(n): 0.39, 0.72, 1.00, 1.52, 2.8, 5.2, 9.54, 19.2, 30.1

equation: a/x^2 + b/x + c log(x) = n*K, where n is an integer


I have to find the best approximate values for the constants a, b, c,
K.

The problem is that the values of n are ANY integer, so instead of
being n= 0, 1, 2, ... it could be n=-19, -18, -17, ...

I need help to: 1. find the best fit for this equation and these

values

(at least for a simple case, such as n= 0, 1, 2...) and 2. see if

there

is a general way of tackling this kind of problem, when the sequence
for n does not have any constraints.

Any help will be very much appreciated.

To get started we must irst understand the problem.
Your given data:
"points x(n): 0.39, 0.72, 1.00, 1.52, 2.8, 5.2, 9.54, 19.2, 30.1"
only makes sense for curve fitting if the following table is used:
n | x(n)
---------
1 | 0.39
2 | 0.72
3 | 1.00
4 | 1.52
5 | 2.8
6 | 5.2
7 | 9.54
8 | 19.2
9 | 30.1
After all, it is a *curve-fitting* problem, and curves must be at least
two-dimensional, so it only makes sense if our points require at least
two coordinates to specify.
Plot x(n) versus n and you will see a curve. A semilog plot is
recommended.
Now you have 9 data points and 4 parameters, giving 5 degrees of
freedom for minimizing whatever criterion you are using to measure
deviation from "best" fit.
If this doesn't at least get you started, let us know.
Tom Davidson
Richmond, VA
.
User: "maison.mousse"

Title: Re: Problem fitting a curve 03 Mar 2005 10:18:10 AM
tadchem a écrit dans le message
<1109861008.762461.316630@g14g2000cwa.googlegroups.com>...


proton wrote:

I have to fit the following points using the given equation:

points x(n): 0.39, 0.72, 1.00, 1.52, 2.8, 5.2, 9.54, 19.2, 30.1

equation: a/x^2 + b/x + c log(x) = n*K, where n is an integer


I have to find the best approximate values for the constants a, b, c,
K.

The problem is that the values of n are ANY integer, so instead of
being n= 0, 1, 2, ... it could be n=-19, -18, -17, ...

I need help to: 1. find the best fit for this equation and these

values

(at least for a simple case, such as n= 0, 1, 2...) and 2. see if

there

is a general way of tackling this kind of problem, when the sequence
for n does not have any constraints.

Any help will be very much appreciated.


To get started we must irst understand the problem.

Your given data:
"points x(n): 0.39, 0.72, 1.00, 1.52, 2.8, 5.2, 9.54, 19.2, 30.1"
only makes sense for curve fitting if the following table is used:

n | x(n)
---------
1 | 0.39
2 | 0.72
3 | 1.00
4 | 1.52
5 | 2.8
6 | 5.2
7 | 9.54
8 | 19.2
9 | 30.1

After all, it is a *curve-fitting* problem, and curves must be at least
two-dimensional, so it only makes sense if our points require at least
two coordinates to specify.

Plot x(n) versus n and you will see a curve. A semilog plot is
recommended.

Now you have 9 data points and 4 parameters, giving 5 degrees of
freedom for minimizing whatever criterion you are using to measure
deviation from "best" fit.

If this doesn't at least get you started, let us know.

Tom Davidson
Richmond, VA

You are correct! If you use the data as above and plot
n on the x axis and x(n) on the log y axis the result is a fairly straight
line.
You might want to look at this site.
http://curvefit.com/
JOL
.
User: "tadchem"

Title: Re: Problem fitting a curve 03 Mar 2005 11:36:28 AM
I took Numerical Analysis back in the '60s, but the basics haven't
changed since then. The algorithms and software have evolved a lot,
though.
In the early '90s I fitted data for the viscosity of about 700 binary
gas mixtures to a one-parameter equation within experimental error.
The parameter was an exponent of 1/3.
Tom Davidson
Richmond, VA
.



User: "GR_GR"

Title: Re: Problem fitting a curve 03 Mar 2005 09:11:04 AM
proton wrote:

I have to fit the following points using the given equation:

points x(n): 0.39, 0.72, 1.00, 1.52, 2.8, 5.2, 9.54, 19.2, 30.1

equation: a/x^2 + b/x + c log(x) = n*K, where n is an integer


I have to find the best approximate values for the constants a, b, c,
K.

The problem is that the values of n are ANY integer, so instead of
being n= 0, 1, 2, ... it could be n=-19, -18, -17, ...

I need help to: 1. find the best fit for this equation and these values
(at least for a simple case, such as n= 0, 1, 2...) and 2. see if there
is a general way of tackling this kind of problem, when the sequence
for n does not have any constraints.

Any help will be very much appreciated.

The correct way to ask for help on these groups are to do as much of the
work as you can, post that, and ask for help with the remainder.
It does not look like you put any thought into the problem.
.
User: "proton"

Title: Re: Problem fitting a curve 03 Mar 2005 10:02:11 AM
Thanks, that really helps and shows that you have understood the
problem thoroughly.
If you want, I can post the tens of pages I've filled in trying to get
the answer manually. But I don't think you'd read beyond the first
line, so I won't bother the rest of the community.
.
User: "Franz Heymann"

Title: Re: Problem fitting a curve 03 Mar 2005 12:02:43 PM
"proton" <leosarasua@gmail.com> wrote in message
news:1109865731.476053.215370@z14g2000cwz.googlegroups.com...

Thanks, that really helps and shows that you have understood the
problem thoroughly.
If you want, I can post the tens of pages I've filled in trying to

get

the answer manually. But I don't think you'd read beyond the first
line, so I won't bother the rest of the community.

You are trying to do a non-linear fit. Orthodox least squares fitting
will get you nowhere. Non-linear least squares fits are no fun.
To do a non-linear fit, you need to guess approximate values for the
parameters, then define new parameters, each being the deviation from
the guessed one. The problem will then be linearised.
You will do yourself and all your readers a favour if you would change
variables such that x becomes y and n becomes x.
Another method is to decide what the function is which you want to
minimise. In your case, this will probably be the sum of the square
deviations. Start with any sensibly guessed set of parameters and use
the numerical method known as the method of steepest decsent to
minimise the square deviation.
Have a look at the following url for a good description of finding a
minimum by themethod of steepest descent
http://trond.hjorteland.com/thesis/node26.html
--
Franz
"A first-rate laboratory is one in which mediocre scientists can
produce outstanding work"
P.M.S. Blackett
.

User: "GR_GR"

Title: Re: Problem fitting a curve 03 Mar 2005 11:52:02 AM
proton wrote:

Thanks, that really helps and shows that you have understood the
problem thoroughly.
If you want, I can post the tens of pages I've filled in trying to get
the answer manually. But I don't think you'd read beyond the first
line, so I won't bother the rest of the community.

In other words... you are too lazy to do your own work.
And if it takes you ten's of pages to fail in solving your problem,
perhaps you should give up?
.



User: "Bjoern Feuerbacher"

Title: Re: Problem fitting a curve 03 Mar 2005 04:48:56 AM
proton wrote:

I have to fit the following points using the given equation:

points x(n): 0.39, 0.72, 1.00, 1.52, 2.8, 5.2, 9.54, 19.2, 30.1

equation: a/x^2 + b/x + c log(x) = n*K, where n is an integer


I have to find the best approximate values for the constants a, b, c,
K.

The problem is that the values of n are ANY integer, so instead of
being n= 0, 1, 2, ... it could be n=-19, -18, -17, ...

I need help to: 1. find the best fit for this equation and these values
(at least for a simple case, such as n= 0, 1, 2...) and 2. see if there
is a general way of tackling this kind of problem, when the sequence
for n does not have any constraints.

Any help will be very much appreciated.

n appears only in the product with the parameter K. So, couldn't you
simply do a fit with a parameter K' = n*K on the right hand side,
and then calculate K=K'/n for different choices of n?
Bye,
Bjoern
.
User: "proton"

Title: Re: Problem fitting a curve 03 Mar 2005 06:47:50 AM
Yes, that's a possibility, In fact, I could divide the whole equation
by K, and get coeffs a', b', c' instead. But the problem still remains
that there seems to be too many degrees of freedom, because of the
lack of constraints on n. Or perhaps not? This is my concern.
Also, if anyone has some software to do the fitting to get at least ONE
solution, it might throw some light into the problem.
Thanks again.
.


User: "Randy Poe"

Title: Re: Problem fitting a curve 03 Mar 2005 12:20:43 PM
proton wrote:

I have to fit the following points using the given equation:

points x(n): 0.39, 0.72, 1.00, 1.52, 2.8, 5.2, 9.54, 19.2, 30.1

equation: a/x^2 + b/x + c log(x) = n*K, where n is an integer


I have to find the best approximate values for the constants a, b, c,
K.

The problem is that the values of n are ANY integer, so instead of
being n= 0, 1, 2, ... it could be n=-19, -18, -17, ...

This can be represented as another free parameter, n0:
a/x^2 + b/x + c log(x) = (n-n0)*K, n = 0, 1, ..., 8
Alternately,
n = p/x^2 + q/x + r log(x) + s
where p = a/K, q = b/K, r = c/K, s = n0.
Note that K is completely arbitrary.
Well, it might be statistically questionable as to
whether it's "best", but if you were to use least-squares
fitting on n as a function of x, i.e., choose p,q,r,s
to minimize sum|a/x^2 + b/x + clog(x) + s - n|^2
then you have a simple linear least-squares problem.
Here's how you set it up. Create a matrix A where each
row represents (1/x^2, 1/x, log(x), 1) for an observation
of x. Let z = your parameter vector (p,q,r,s)'.
Then you are trying to find z the least-squares
solution to:
Az = b
where b = (0,1,2,...)'
That is, you're trying to find z which minimizes
|Az-b|^2 = (Az-b)'(Az-b)
= z'A'Az + b'b - 2b'Az
The value of z which minimizes this is the solution
to the linear system:
A'Az = A'b
which you could find as z = (A'A)^(-1) * A'b but it's
more efficient to use a linear solver if you have one.
The solution I get by the way is
p = 0.2365
q = -1.211
r = 1.460
s = 2.895
I can choose K = anything I like, so I'll choose 1.
The nearest integer to s is 3, so if I round that
off I get:
m = 0.2365/x^2 - 1.211/x + 1.46*log(x)
where m = n-3 = -3, -2, ..., 5
- Randy
.
User: "proton"

Title: Re: Problem fitting a curve 03 Mar 2005 12:30:07 PM
Thanks a lot. This is just what I was looking for! Of course, now that
I look at it, it seems almost trivial to add the extra parameter n0,
but I just didn't see it.
Thanks to all the others who've tried to help as well; some of your
tips were very valuable.
.



  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1612     pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER