How to calculate standard deviation of circular data

耗尽温柔 提交于 2020-02-24 03:54:30

问题


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

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)

回答1:


You may use the circular package for that:

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

Manually,

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

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

See also here and here.



来源:https://stackoverflow.com/questions/55616697/how-to-calculate-standard-deviation-of-circular-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!