function AndrzejakKreuzExample
% 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.
% Important note: The execution of this source code can take relatively
% long (5-10 min), even on fast computers. In general it holds that the larger the
% distance matrices, the more time is needed for the computation.
% Accordingly, decreasing the signal length Q and/or increasing the step-size
% s reduces the computation time but might also reduce the performance of
% the measure. You will have to find a good setting for your data, depending
% on their amount of data, length, delta_t, your computational resources, etc.
% Load five signals and display their names and sizes
load AndrzejakKreuzExampleData
tic
whos
% Define parameters
disp('Defining parameters');
Q = size(signal1,1);
q = 1000;
s = 200;
dt= 1;
k = 1;
W = round(q/s)-1; % see remark 1 below
dchoice = 2;
% Calculate distance matrices from flows
disp('Calculating distance matrices from flows');
DF_1 = AndrzejakKreuzDflow(signal1,Q,q,s,W);
DF_2 = AndrzejakKreuzDflow(signal2,Q,q,s,W);
% Calculate distance matrices from the point processes
disp('Calculating distance matrices from point processes. Please be patient');
DP_3 = AndrzejakKreuzDpointprocess(signal3,Q,q,s,W,dt,dchoice);
% Now all distance matrices can be treated the same and stacked in Darray
DArray(:,:,1) = DF_1;
DArray(:,:,2) = DF_2;
DArray(:,:,3) = DP_3;
% Calculation of the actual measure L
disp('Calculating of the actual measure L');
L = AndrzejakKreuzL(DArray,k,W);
% Display the output, in L(i,j) we have L(signal i | signal j)
disp(L);
% remark 1
% To keep things simple, q/s should be an integer. Since later W is used a
% array index, we use 'round', to cut off possible round of errors. If you
% want to use non-integer ratios, you should use 'ceil' instead of 'round'.
toc
end