I have two event signals, A and B, over time. For both signals, the value at time t represents the number of occurences of the event at that time. Now I want to determine if either events, A or B occur iff the other occurs. That is to say, does event A occur when B occurs, does event B occurs when A occurs.
I believe this is simply the correlation between the both. However I do not want the correlation when both events are not occuring. My current approach is as follows:
We have signals A and B, so A(1) represents the number of occurences of event A at time 1. First I sort the two signals A and B, but I am only interested in the sorted indices.
[~,idxA] = sort(A); [~,idxB] = sort(B);
I retrieve the indices where the number of occurences for both A and B are zero
idx = A(idxA) == 0 & B(idxA) == 0;
From the array of indices which is sorted I remove all the parts where the events for both A and B was none. What I am left with are the indices (time) where either an event of A or B occurs or an event for both A and B occurs.
idxA(idx) = ; idxB(idx) = ;
Then I calculate the correlation between those two arrays.
Now I wonder is this approach correct? I uploaded the data here: https://pastebin.com/3QnH8KkL