如何找到一组轴承的平均值
可能的重复:
如何计算一组的平均值角度?
如果我有一组方位角,范围从 1-360,我怎样才能找到平均值?通常要找到平均值,请将它们全部加起来并除以项目数。这里的问题是,在 [1, 359]、2 个轴承的情况下这样做会导致 180,实际上应该是 360。有什么想法吗?
Possible Duplicate:
How do you calculate the average of a set of angles?
If I have a set of bearings, ranging from 1-360, how can I find the average? Usually to find the average one would add them all up and divide by the number of items. The problem here is that doing that in the case of [1, 359], 2 bearings, would result in in 180, which in fact should be 360. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将角度表示为 Norm=1 的向量并对总和求平均值。
这意味着平均值的角度是,
当分母接近零时,请注意控制可能的溢出。
Represent the angles as vectors with Norm=1 and average the sum.
which means the angle for the mean is
Just beware of controlling the possible overflow when the denominator is close to zero.
从你的问题中并不清楚你试图定义“平均”是什么......对于圆上的方向,没有明确明显的平均概念。
一种解释是值
x
,它在最小二乘意义上最接近提供的值集,其中两个轴承之间的距离定义为它们之间的最小角度。以下是计算该平均值的代码:It isn't clear from your question what you're trying to define the "average" to be... for directions on a circle there is no clear-cut obvious notion of average.
One interpretation is the value
x
that is the closest fit to the set of provided values, in the least-squares sense, where the distance between two bearings is defined as the smallest angle between them. Here is code to compute this average:所以你想要的是两个轴承的中间 - 如果你有 {90, 270} 会发生什么?想要的答案是0还是180?这是需要考虑的事情..三个轴承的中间是什么?
您可以做的一件事是:
在我的脑海中,我认为这不会是公平的,但它可能会偏向一个方向(即可能会优先于您集合中后面的值)。
So what you want is the middle of two bearings - what happens if you have {90, 270}? Is the desired answer 0 or 180? This is something to consider.. also what's the middle of three bearings?
One thing you could do is:
Off the top of my head, I don't think this is going to be fair, it'll probably bias it in one direction though (i.e. maybe in preference of the later values in your set).