% STATISTICS evaluates basic spike train (sX) statistics:
% mean interval (mTau) and variance (varTau) of the interspike intervals,
% coefficient of variation (CV)

function [mTau,varTau,CV] = statistics(sX);

% mean interval:

n = length(sX);
mTau = 0; 
for i = 2:n
    mTau = mTau + sX(i) - sX(i-1);
end
mTau = mTau/(n-1);
% mTau = (sX(n) - sX(1))/(n-1);  % equivalent to the whole 'for' loop

% variance

varTau = 0;
for i = 2:n
    varTau = varTau + (sX(i) - sX(i-1) - mTau)^2;
end
varTau = varTau/(n-1);

% CV

CV = sqrt(varTau)/mTau;








