% Compute the covariance coefficient between the spike trains % p1 and p2 by taking the integral of the crosscorrelation function % over a window of radius tau and correcting. % Multiply this number by tau to get the covariance of the % spike count over an interval of size tau. % c=cov_coeff(p1,p2,tau,dt) % dt is the binsize % NOTE: p1 and p2 should be the same length function c=cov_coeff(p1,p2,tau,dt) % T is the length of p1 in the correct units n=numel(p1); T=n*dt; % Define the correction term 'function' correctionterm=1-abs((-tau:dt:tau))/tau; % Calculate the correlation function [cc12,x]=cross_corr(p1,p2,tau,dt); % Integrate the correlation function % multiplying by the correctino term c=sum(correctionterm.*cc12)*dt;