3D 最小二乘平面 [英] 3D Least Squares Plane

查看:29
本文介绍了3D 最小二乘平面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一组 3D 数据点,计算 (x, y, z) 空间中最小二乘平面的算法是什么?换句话说,如果我有一堆点,如 (1, 2, 3), (4, 5, 6), (7, 8, 9) 等,人们将如何计算最佳拟合平面 f(x, y) = ax + by + c?从一组 3D 点中获取 a、b 和 c 的算法是什么?

What's the algorithm for computing a least squares plane in (x, y, z) space, given a set of 3D data points? In other words, if I had a bunch of points like (1, 2, 3), (4, 5, 6), (7, 8, 9), etc., how would one go about calculating the best fit plane f(x, y) = ax + by + c? What's the algorithm for getting a, b, and c out of a set of 3D points?

推荐答案

如果您有 n 个数据点 (x[i], y[i], z[i]),请计算 3x3 对称矩阵 A,其条目为:

If you have n data points (x[i], y[i], z[i]), compute the 3x3 symmetric matrix A whose entries are:

sum_i x[i]*x[i],    sum_i x[i]*y[i],    sum_i x[i]
sum_i x[i]*y[i],    sum_i y[i]*y[i],    sum_i y[i]
sum_i x[i],         sum_i y[i],         n

同时计算 3 元素向量 b:

Also compute the 3 element vector b:

{sum_i x[i]*z[i],   sum_i y[i]*z[i],    sum_i z[i]}

然后针对给定的 A 和 b 求解 Ax = b.解向量的三个分量是最小二乘拟合平面 {a,b,c} 的系数.

Then solve Ax = b for the given A and b. The three components of the solution vector are the coefficients to the least-square fit plane {a,b,c}.

请注意,这是普通最小二乘法"拟合,仅当 z 预期为 x 和 y 的线性函数时才适用.如果您更广泛地寻找 3 空间中的最佳拟合平面",您可能想了解几何"最小二乘法.

Note that this is the "ordinary least squares" fit, which is appropriate only when z is expected to be a linear function of x and y. If you are looking more generally for a "best fit plane" in 3-space, you may want to learn about "geometric" least squares.

另请注意,如果您的点在一条线上,就像您的示例点一样,这将失败.

Note also that this will fail if your points are in a line, as your example points are.

这篇关于3D 最小二乘平面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆