Rank: 168807 based on 0 downloads (last 30 days) and 0 file submitted



Personal Profile:


Watch this Author's files


Comments and Ratings by Ryan
Updated File Comments Rating
16 Aug 2012 Circular Statistics Toolbox (Directional Statistics) Compute descriptive and inferential statistics for circular or directional data. Author: Philipp Berens

I haven't run through this toolbox yet, so I apologize if I am missing something with this question (I just glanced through the source code because I am interested in directional stats).

When you calculate the mean, the formula you use is:

% compute weighted sum of cos and sin of angles
r = w'*exp(1i*alpha);

% obtain mean by
mu = angle(r);

Now, correct me if I'm wrong, but this doesn't seem to calculate the average at all? It seems to me that here we are inputting a data array into the angle command, which will output the phase angle of each element of that array, not a singular mean.

Wouldn't a better way of calculating the average be to use atan2? Something like:

for i = 1:w
S(i) = sin(alpha(i));
C(i) = cos(alpha(i));

X = sum(S)*(1/w);
Y = sum(C)*(1/w);

mu = atan2(X,Y);

Contact us