function DF=AndrzejakKreuzDflow(flow,Q,q,s,W)

% For further information, please refer to AndrzejakKreuzReadme.pdf and to
% Andrzejak RG, Kreuz T: Characterizing unidirectional couplings between point processes and flows. EPL, 96 (2011) 50012.


N=fix((Q-q)/(s)+1);
DF=zeros(N,N);
for wc1=1:N
     for wc2=wc1+W+1:N
          DF(wc1,wc2)=sum((flow(round((wc2-1)*s+1):round((wc2-1)*s+q))-flow(round((wc1-1)*s+1):round((wc1-1)*s+q))).^2);         
     end    
 end
DF= DF+DF';
