Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

circ_median wrong warning "ties detected" #21

Open
Irismoon opened this issue Apr 30, 2020 · 0 comments
Open

circ_median wrong warning "ties detected" #21

Irismoon opened this issue Apr 30, 2020 · 0 comments

Comments

@Irismoon
Copy link

Irismoon commented Apr 30, 2020

Thanks for the code.

  1. I found out circ_median handle one situation wrong. say, beta=[1 2 2 4 4 6], according to the code of circ_median below, dm = [5 2 2 2 2 5], m = 2, idx = [2 3], md = 2. But md should be the mean of 2 and 4, i.e., 3. Therefore, it seems circ-median handle this case wrong.
dd = circ_dist2(beta,beta);
  m1 = sum(dd>=0,1);
  m2 = sum(dd<=0,1);

  dm = abs(m1-m2);
  if mod(n,2)==1
    [m, idx] = min(dm);
  else
    m = min(dm);
    idx = find(dm==m,2);
  end

  if m > 1
    warning('CIRCSTAT:circ_median:tiesDetected', ...
        'Ties detected.') %#ok<WNTAG>
  end
 md = circ_mean(beta(idx));

To correct it, I suggest change the last part into,

else
    m = min(dm);
    idx = find(dm==m);%
end
if m>1 && length(unique(beta(idx)))~=2 
warning('')% same as above
md = circ_mean(beta(idx))
  1. In the original circ_median, assuming beta = 0:pi/3:2pi, then each phase should be the median. However, from m = min(dm); idx = find(dm==m,2), it seems it only includes the first two phases, rather than take them all. I simply suggest change it into idx = find(dm==m).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant