# forum.alglib.net

ALGLIB forum
 It is currently Fri Jul 19, 2024 4:54 am

 All times are UTC

### Forum rules

1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.

 Page 1 of 1 [ 8 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Linear Regression in 3d (three independent variables)Posted: Fri May 14, 2010 2:55 pm

Joined: Fri May 14, 2010 2:52 pm
Posts: 3
Hi!

First of all I have to say that you're doing a great job with your library. Keep going!

Second, I'd like to question something...
Is it possible with the ALGLib to compute a Linear Regression in 3d? I want to calculate a line in 3d from a group of points in 3d. I want that line to be a regression line from a cloud of points that are candidates to be there. Each point has a value of the 'chance' to be part of the line.

I thought that a linear regression could do this for me. Can I do it with the library?

Thanks!!

Top

 Post subject: Re: Linear Regression in 3d (three independent variables)Posted: Sat May 15, 2010 7:04 am

Joined: Fri May 07, 2010 7:06 am
Posts: 921
Quote:
I want that line to be a regression line from a cloud of points that are candidates to be there. Each point has a value of the 'chance' to be part of the line.

Do you really have probabilities, i.e. values strictly within [0,1]? Or just "likelihood values"? Do line have to pass exactly through all points, which are "part of it"? If answers are "probability" and "exactly", then ALGLIB can't solve this task. And I've never heard of regression problem like this.

However you can use linear regression unit to find approximate answer - just set weights to probability values (or square roots of values, I'm not sure) and get approximate line.

Top

 Post subject: Re: Linear Regression in 3d (three independent variables)Posted: Sat May 15, 2010 10:49 am

Joined: Fri May 14, 2010 2:52 pm
Posts: 3

The values are not probabilities, there are more likelihood values, and it doesn't have to pass exactly through none of the points.

The problem is that I don't know what function of the library use, I have to use lrbuild? And in that case, how do I fill the variable 'xy'. Because that is just a ap:real_2d_array and I have to handle X, Y, Z, and the value of likelihood (that you recommend me to set the weights, where do I do that?

Thanks again! You're going to be very usefull!!

Top

 Post subject: Re: Linear Regression in 3d (three independent variables)Posted: Sat May 15, 2010 11:50 am

Joined: Fri May 07, 2010 7:06 am
Posts: 921
Now I see - it is weighted principal component analysis problem, not linear regression one. You can use MinLM (or MinLBFGS) unit to minimize F(a,b,c), which is weighted sum of squared distances from points to the line defined by (a,b,c).

Don't know, however, how weights should come into F() - as w[i], or as w[i] squared... You can try both, and see what give you best results.

Top

 Post subject: Re: Linear Regression in 3d (three independent variables)Posted: Sat May 15, 2010 4:09 pm

Joined: Fri May 14, 2010 2:52 pm
Posts: 3
I have another question... that MinLM seems to be useful for NON-LINEAR FITTING. I want to do a linear fitting, because the result that I want to get is a line that "fits" that cloud of points.

I read in the documentation of the functions that MinLM is for NON-LINEAR.

I get these cloud of points from the intersection of the normals of some faces. The idea is that the rotation axis is the line that fit (not exactly but very approximately) the points of the cloud that has more value (the amount of intersection of normals in that point).

First of all I think to use a Hough transform, that is used to detecting shapes (for example a line) in images. So I has the idea of expanding to 3D instead of 2D. But looking for information I saw that a Linear Regression could be useful because, at the end, I want to fit a line from a cloud of points.

I hope that with these little explanation of the problem I'd explained myself more.

So, do you think that MinLM could handle my problem?

Thanks!!

Top

 Post subject: Re: Linear Regression in 3d (three independent variables)Posted: Mon May 17, 2010 6:06 am

Joined: Fri May 07, 2010 7:06 am
Posts: 921
MinLM may be used both for linear and non-linear fitting (linear function is just a special case of non-linear function). But your task is really nonlinear (although it seems linear at the first glance). Try to write equations for distance between your line and point in the space - you won't get linear function. So nonlinear fitting (with MinLM or MinLBFGS) is the only way to solve your problem.

P.S. Try to read something on total least squares. It looks very close to your problem (although you have slightly different formulation: LS deals with restoration of noised dependencies, you want to maximize some merit function). Maybe you'll find some ideas which may help you...

Top

 Post subject: Re: Linear Regression in 3d (three independent variables)Posted: Sat Jan 17, 2015 6:31 am

Joined: Sat Jan 17, 2015 6:30 am
Posts: 1
You don't include probabilities, my spouse and i. electronic. beliefs totally within [0, 1]? Or maybe "likelihood values"? Do range need to pass accurately as a result of many things, which are "part involving it"? If answers are "probability" in addition to "exactly", after that ALGLIB can not clear up this task. Along with I've by no means got word of regression trouble similar to this.

On the other hand you may use linear regression device to get approx . remedy -- just fixed weights in order to probability beliefs (or sq . sources involving beliefs, I am just certainly not sure) and have approx . range.

Top

 Post subject: Re: Linear Regression in 3d (three independent variables)Posted: Sat Feb 14, 2015 10:27 am

Joined: Sat Feb 14, 2015 7:26 am
Posts: 1
I read in the documentation of the functions that MinLM is for NON-LINEAR. I get these cloud of points from the intersection of the normals of some faces. The idea is that the rotation axis is the line that fit (not exactly but very approximately) the points of the cloud that has more value (the amount of intersection of normals in that point). ???

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 8 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 15 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for: