forked from open-ephys/simpleclust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_ks.m
21 lines (16 loc) · 617 Bytes
/
test_ks.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function [KSmax] = test_ks(x)
%
% Calculates the CDF (expcdf)
[y_expcdf,x_expcdf]=cdfcalc(x);
%
% The theoretical CDF (theocdf) is assumed to be normal
% with unknown mean and sigma
zScores = (x_expcdf - mean(x))./std(x);
theocdf = normcdf(zScores , 0 , 1);
%
% Compute the Maximum distance: max|S(x) - theocdf(x)|.
%
delta1 = y_expcdf(1:end-1) - theocdf; % Vertical difference at jumps approaching from the LEFT.
delta2 = y_expcdf(2:end) - theocdf; % Vertical difference at jumps approaching from the RIGHT.
deltacdf = abs([delta1 ; delta2]);
KSmax = max(deltacdf);