如何找到一组轴承的平均值

发布于 2024-10-20 03:14:18 字数 311 浏览 1 评论 0原文

可能的重复:
如何计算一组的平均值角度?

如果我有一组方位角,范围从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

百合的盛世恋 2024-10-27 03:14:18

将角度表示为 Norm=1 的向量并对总和求平均值。

x1 = {cos(a),sin(a)}

x2 = {cos(b),sin(b)} 

(x1+x2)/2 = {(cos(a)+cos(b))/2,(sin(a)+sin(b))/2} 

这意味着平均值的角度是,

atan2((sin(a)+sin(b)) /(cos(a)+cos(b)))  

当分母接近零时,请注意控制可能的溢出。

在此处输入图像描述

Represent the angles as vectors with Norm=1 and average the sum.

x1 = {cos(a),sin(a)}

x2 = {cos(b),sin(b)} 

(x1+x2)/2 = {(cos(a)+cos(b))/2,(sin(a)+sin(b))/2} 

which means the angle for the mean is

atan2((sin(a)+sin(b)) /(cos(a)+cos(b)))  

Just beware of controlling the possible overflow when the denominator is close to zero.

enter image description here

梦冥 2024-10-27 03:14:18

从你的问题中并不清楚你试图定义“平均”是什么......对于圆上的方向,没有明确明显的平均概念。

一种解释是值x,它在最小二乘意义上最接近提供的值集,其中两个轴承之间的距离定义为它们之间的最小角度。以下是计算该平均值的代码:

In[2]:= CircDist[a_, b_] := 180 - Mod[180 + a - b, 360]

In[6]:= Average[bearings_] := 
 x /. NMinimize[
    Sum[CircDist[x, bearings[[i]]]^2, {i, 1, Length[bearings]}], 
    x][[2]]

In[10]:= Average[{1, 359}]

Out[10]= -3.61294*10^-15

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:

In[2]:= CircDist[a_, b_] := 180 - Mod[180 + a - b, 360]

In[6]:= Average[bearings_] := 
 x /. NMinimize[
    Sum[CircDist[x, bearings[[i]]]^2, {i, 1, Length[bearings]}], 
    x][[2]]

In[10]:= Average[{1, 359}]

Out[10]= -3.61294*10^-15
回眸一笑 2024-10-27 03:14:18

所以你想要的是两个轴承的中间 - 如果你有 {90, 270} 会发生什么?想要的答案是0还是180?这是需要考虑的事情..三个轴承的中间是什么?

您可以做的一件事是:

  • 取出集合中的前两个方位角,
  • 计算出两个方位角在任一方向上的差异(即 [1, 359] 在一个方向上给出 2 度,在另一个方向上给出 358 度)
  • 如果您想要所需的角度是两个中最锐角的中间,将其作为差值并添加到逆时针方向的大部分(即 359),
  • 使用这个作为新轴承,下一个(即组中的第三个)作为其他轴承,然后重复,直到所有轴承都处于“中间”。

在我的脑海中,我认为这不会是公平的,但它可能会偏向一个方向(即可能会优先于您集合中后面的值)。

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:

  • Take the first two bearings in your set
  • Work out the difference between the two in either direction (i.e. [1, 359] would give 2 degrees in one direction, and 358 in the other)
  • If you want the desired angle to be the middle of the acutest of the two, take that as your difference and add to the anti-clockwise most of the pair (i.e. 359)
  • Use this as the new bearing and the next (i.e. 3rd in set) as the other bearing, and repeat, until all are 'middled'.

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文