matlab 角度方差
我有一个包含角度的矩阵,我需要计算平均值和方差。 对于平均而言,我以这种方式进行: 对于每个角度计算 sin 和 cos 并对所有 sin 和 cos 求和 平均值由 atan2(sin, cos) 给出 它有效 我的问题是如何计算已知平均值的角度方差?
感谢您的回答
我附上我的matlab代码:
for i=1:size(im2,1)
for j=1:size(im2,2)
y=y+sin(hue(i, j));
x=x+cos(hue(i, j));
end
end
mean=atan2(y, x);
if mean<0
mean=mean+(2*pi);
end
I have a matrix containing angles and I need to compute the mean and the variance.
for the mean I procede in this way:
for each angles compute sin and cos and sum all sin and all cos
the mean is given by the atan2(sin, cos)
and it works
my question is how to compute the variance of angles knowing the mean?
thank you for the answers
I attach my matlab code:
for i=1:size(im2,1)
for j=1:size(im2,2)
y=y+sin(hue(i, j));
x=x+cos(hue(i, j));
end
end
mean=atan2(y, x);
if mean<0
mean=mean+(2*pi);
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为了计算角度的方差,您不能使用标准方差。这是计算角度 var 的公式:
还有类似的其他公式:
参考:
http://www.ebi.ac.uk/ thornton-srv/software/PROCHECK/nmr_manual/man_cv.html
In order to compute variance of an angle you can not use standard variance. This is the formulation to compute var of an angles:
There is similar other formulation as well:
Ref:
http://www.ebi.ac.uk/thornton-srv/software/PROCHECK/nmr_manual/man_cv.html
我不是 100% 确定你在做什么,但也许这可以通过在 MATLAB 函数中构建实现相同的效果 均值 和var。
编辑:我假设您有一个图像,因为您的变量名称
hue
。但对于任何矩阵来说都是一样的。编辑2:也许这就是您正在寻找的:
I am not 100% sure what you are doing, but maybe this would achieve the same thing with the build in MATLAB functions mean and var.
EDIT: I am assuming you have an image because of your variable name
hue
. But it would be the same for any matrix.EDIT 2: Maybe that is what you are looking for:
循环数据的方差不能像实线上无界数据的方差一样对待。 (对于非常小的方差,它们实际上是等价的,但是对于大的方差,等价性就会被破坏。您应该清楚这是为什么。)我推荐 NI Fisher 的循环数据统计分析。本书包含广泛使用的圆方差定义,该定义是根据与角度相对应的单位向量的平均合成长度计算得出的。
是错误的。你不能这样减去角度。
顺便说一句,这个问题确实与MATLAB无关。您可能可以在统计堆栈交换上发布更多/更好的答案
The variance of circular data can not be treated like the variance of unbounded data on the real line. (For very small variances, they are effectively equivalent, but for large variances the equivalence breaks down. It should be clear to you why this is.) I recommend Statistical Analysis of Circular Data by N.I. Fisher. This book contains a widely-used definition of circular variance that is computed from the mean resultant length of the unit vectors that correspond to the angles.
is wrong. You can't subtract angles like that.
By the way, this question really has nothing to do with MATLAB. You can probably get more/better answers posting on the statistics stack exchange
我们遇到了同样的问题,在 python 中,我们可以使用 scipy.cirvar 来解决这个问题,它计算假设在某个范围内的样本的循环方差。例如:
所提出的 MATLAB 代码的问题是
[0, 6.28]
的方差应为零。通过查看 scipy.circvar 的实现,它就像:We had the same problem and in python, we could fix that with using
scipy.cirvar
which computes the circular variance for samples assumed to be in a range. For example:The problem with the proposed MATLAB code is that the variance of
[0, 6.28]
should be zero. By looking at the implementation ofscipy.circvar
it is like: