• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Best fit program in Python

Chaotic42

Lifer
Hey folks.

I need an algorithm to determine the coordinates of a best fit plane in 3D space given data.

For example, if you're given 65 3D coordinates, I need to figure out what rectangular 2D plane will best fit that data. I've been looking around and haven't found anything yet, I figured I'd ask and see if anyone knows off hand.

Thanks.
 
Disclaimer: I know next to nothing about Python. I'm a Perl/everything else guy. One of these days I'll learn Python, I swear

You'll want to do matrix left division using least-squares approximation. Basically you're solving the equation A*X = B where A is a m x 3 matrix consisting of your x, y, and const column vectors and B is a m-column vector consiting of your z points. The solution (X) will be your coefficients to your best-fit plane (z = ax + by + c). In Java, you use the solve() method on the Matrix class. You're probably going to have to do the math yourself in Python unless there's a math (package?) somewhere that does it for you. A quick search turned up a couple of possibilities.

ScientificPython

or

SciPy

I have no idea if that helps, but it's worth a look.
 
Hmm... Matrix stuff. I haven't done that yet in my studies.

Thanks for the post, I'm going to have to do some reasearch.
 
Back
Top