help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: test a cloud of 2D points for linearity


From: Joshua Stults
Subject: Re: test a cloud of 2D points for linearity
Date: Wed, 27 May 2009 12:11:07 -0400

Check out:
http://en.wikipedia.org/wiki/Principal_components_analysis

It breaks down your cloud into principal component vectors.  Octave
has svd() to do the singular value decomposition yourself, or
princomp().  In your case it sounds like you only care about the first
principle component.

Maybe if you're more interested in the "goodness" of the fit, R
(www.r-project.org) might be the more appropriate tool, it has lots
more statistical tests already implemented than Octave, not that you
can't do it in Octave, you'd just have to do it yourself.

On Wed, May 27, 2009 at 12:00 PM, Georg P. Israel <address@hidden> wrote:
> Dear Josua,
>
> I don't understand your question.
> Sorry, I am out of training with this math stuff.
>
> Here my problem,
> I have a number of points in a 2D surface.
> This points exhibit some sort of a linear arrangement.
> This means, if you look at them, they look like a line.
>
> But this line can have any direction on the surface.
> They can be horizontal, vertical or any other intermediate direction.
>
> The only thing I need is a function that returns me some sort of measure
> about how good this points resembel a line.
> Important is that this function has to be independen of the angle.
> Hence, the same cloud as to give the same result, even if I rotate the
> cloud on the plain.
>
> Any idea ???
>
> Best  regards
>
> Georg P. Israel
>
>
>
> On Wed, 2009-05-27 at 11:52 -0400, Joshua Stults wrote:
>> So you're doing principle component analysis, not least squares regression?
>>
>> On Wed, May 27, 2009 at 11:44 AM, Georg P. Israel <address@hidden> wrote:
>> > Dear Joshua,
>> >
>> > it might that I miss understand the polyfit function.
>> >
>> > I had the impression that this will fit a simple polynom of y=a+b*x into
>> > the cloud of points.
>> > This will work OK if the cloud has a horizontal shape.
>> > Then "b" -> 0 . In this case, the root mean square of the cloud is
>> > computed correctly with there orthogonal distance to the line.
>> >
>> > But now, consider that the cloud of points gets rotated by 90 degree.
>> > In this case, the
>> > "b" -> infinity.
>> > Even worse, the root mean square (RMS) distance of the cloud points to
>> > the line is now not computed with there orthogonal distance!!
>> >
>> > Hence, the RMS distance of the cloud points to the line will depend very
>> > much on the angle of the line.
>> >
>> > Now, I need something that fits a line trough the cloud of points and
>> > then computes the orthogonal root means square distance of the cloud
>> > points from the line.
>> >
>> > Best regards
>> >
>> > Georg P. Israel
>> >
>> >
>> >
>> >
>> > On Wed, 2009-05-27 at 11:30 -0400, Joshua Stults wrote:
>> >> Probably
>> >>
>> >> [P, S] = polyfit(x, y, 1)
>> >>
>> >> will do what you want.  The second output argument gives lots of
>> >> useful diagnostic info on the fit; also check out polyval().
>> >>
>> >> On Wed, May 27, 2009 at 10:56 AM, Georg P. Israel <address@hidden> wrote:
>> >> > Dear all,
>> >> >
>> >> > I am almost ashamed to ask this stupid question,
>> >> > but with all this wealth of function, i seem to not find the right
>> >> > stuff. Even thought, I know that it is there, probably just under my
>> >> > nose.
>> >> >
>> >> > here my problem:
>> >> >
>> >> > I have a number of points in a plain (2D points)
>> >> > This points can have an arbitrary distribution.
>> >> > I would like to have a function that will fit the line through this
>> >> > cloud of points.
>> >> >
>> >> > I expect that one point of this line is the mean of all points plus some
>> >> > direction vector.
>> >> >
>> >> > The next thing that I like to have now is the RMS of all the distances
>> >> > of the points along this line. This is basically a variance as seen
>> >> > along this line.
>> >> >
>> >> > Now, I can certainly start to clumsily develop this function, but I am
>> >> > sure that I am just overlooking the right function.
>> >> >
>> >> > Hence,
>> >> > please point my nose this this function ...
>> >> >
>> >> > Best regards
>> >> >
>> >> > Georg P. Israel
>> >> >
>> >> >
>> >> >
>> >> > _______________________________________________
>> >> > Help-octave mailing list
>> >> > address@hidden
>> >> > https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>> >> >
>> >>
>> >>
>> >>
>> >
>> >
>>
>>
>>
>
>



-- 
Joshua Stults
Website: http://j-stults.blogspot.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]