Skip to content

circ_median wrong warning "ties detected" #21

@Irismoon

Description

@Irismoon

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions