Re: best linear fit to a curve
- From: "Jonathan Schell" <jschell@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 25 Mar 2008 15:57:02 +0000 (UTC)
"John D'Errico" <woodchips@xxxxxxxxxxxxxxxx> wrote in
message <fsa676$2vl$1@xxxxxxxxxxxxxxxxxx>...
"Jonathan Schell" <jschell@xxxxxxxxxxxxxxxxxxxx> wrote inmessage
<fs9kd5$4r0$1@xxxxxxxxxxxxxxxxxx>...2-d array
"John D'Errico" <woodchips@xxxxxxxxxxxxxxxx> wrote in
message <fs9jit$ra8$1@xxxxxxxxxxxxxxxxxx>...
"Jonathan Schell" <jschell@xxxxxxxxxxxxxxxxxxxx> wrote inmessage
<fs9ih7$ih7$1@xxxxxxxxxxxxxxxxxx>...
I have a curve defined by a series of points in a
the bestand I need to get the best linear approximation for it.
More specifically, I need the 8 points that will be
figure outlinear fit for the curve. I don't know the correct
terminology so I don't know what to search for to
where to puthow to do this. Right now I'm just guessing at
adjusting itthe points based on looking at the graph and
figure thisuntil it looks ok, but I'd like the computer to
graphed.out for me. :)
Please be more specific.
Do you have a function y = f(x), with a single
independent variable. Now you want to find
that subset of 8 of your points which yields
the best linear fit?
Or have I misunderstood the problem?
John
No, I don't have a function. I have a set of points,
anywhere from 2 to 3000, in an array. It's just a sequence
of x,y coordinates. I need the 7 best fitting lines (8
points) that will most closely resemble that curve when
Ok. So you wish to find a piecewise linear
approximation to your curve. I'd never have
guessed this from your first post.
The problem is its not hard if you are willing
to define the breakpoints in advance. Then
its really just a least squares linear spline.
You can find this in the splines toolbox.
If you are not willing to fix the break points
in advance, then its a free knot spline problem.
Estimation of the knot positions is quite a
bit more difficult, although there are several
algorithms out there that try to do so.
Simplest is just to use the optimization
toolbox to find the breaks, though even
that has issues. Other methods (MARS) use
stepwise regression methods to insert knots
until the desired number have been placed.
John
Piecewise linear approximation sounds right. I want to
break my curve into segments and get the closest linear
approximation to the curve, but I want to be able to
calculate where to make the break rather than set them
manually, which is what I'm doing now. I'm assuming that
this is what you mean when you say "break points".
I can write a program that will try all the possible spots
along the curve and test each time to see which spots create
the best fit for all 7 segments, but I wanted to know if
Matlab already had that functionality, because it would be
easier to script it in Matlab than to write it in C or Fortran.
.
- Follow-Ups:
- Re: best linear fit to a curve
- From: John D'Errico
- Re: best linear fit to a curve
- References:
- best linear fit to a curve
- From: Jonathan Schell
- Re: best linear fit to a curve
- From: John D'Errico
- Re: best linear fit to a curve
- From: Jonathan Schell
- Re: best linear fit to a curve
- From: John D'Errico
- best linear fit to a curve
- Prev by Date: Re: PSD - Which method?
- Next by Date: Re: how to pass parameters from matlab to simulink
- Previous by thread: Re: best linear fit to a curve
- Next by thread: Re: best linear fit to a curve
- Index(es):
Relevant Pages
|