如何计算圆形数据的标准偏差 [英] How to calculate standard deviation of circular data

查看:272
本文介绍了如何计算圆形数据的标准偏差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已遵循此处提出的建议来计算循环数据的平均值:

I've followed the advice laid out here for calculating the average of circular data:

https://en.wikipedia.org/wiki/Mean_of_circular_quantities

但是我也想计算标准差.

But I'd also like to calculate standard deviation as well.

#A vector of directional data (separated by 20 degrees each)
Dir2<-c(350,20,40)

#Degrees to Radians
D2R<-0.0174532925

#Radians to Degrees
Rad2<-Dir2 * D2R


Sin2<-sin(Rad2)
SinAvg<-mean(Sin2)

Cos2<-cos(Rad2)
CosAvg<-mean(Cos2)

RADAVG<-atan2(SinAvg, CosAvg)
DirAvg<-RADAVG * R2D

以上是我的平均值,但我不知道如何计算SD

The above gives me the average, but I don't know how to calculate the SD

我试图只取正弦和余弦的标准偏差的平均值,但是得到的答案却不尽相同.

I tried to just take the mean of the standard deviation for both the sine and cos, but I get varying answers.

SinSD<-sd(Sin2)
CosSD<-sd(Cos2)
mean(CosSD, SinSD)

推荐答案

您可以为此使用circular包:

x <- circular(Rad2)
mean(x)
# Circular Data: 
# Type = angles 
# Units = radians 
# Template = none 
# Modulo = asis 
# Zero = 0 
# Rotation = counter 
# [1] 0.2928188 # The same as yours
sd(x)
# [1] 0.3615802

手动

sqrt(-2 * log(sqrt(sum(Sin2)^2 + sum(Cos2)^2) / length(Rad2)))
# [1] 0.3615802

可以从sd.circular的源代码中看到.

which can be seen from the source code of sd.circular.

另请参见此处此处.

这篇关于如何计算圆形数据的标准偏差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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