I would like to calculate the difference between two data sets at any given moment in time. The problem is that the "timestamps" at which both data sets were taken differ. For example consider these data sets
time-1 state-1 time-2 state-2
6.164012 1 6.164015 1
6.290051 2 6.290055 2
6.454675 3 6.454678 3
7.006175 4 7.006178 4
7.080418 5 7.016555 5
7.193570 6 7.016595 4
7.351850 7 7.016595 3
7.465638 8 7.016595 2
7.492480 9 7.080421 3
7.524426 10 7.193572 4
8.006629 11 7.203975 5
It would be even sufficient to have the difference between state-1 and state-2 calculated at each 0.000001 seconds (brute force). Does anybody know how to solve this issue?
EDIT: To clearify my question: the first data set contains a time stamp (time-1) and a corresponding value (state-1); the second data set contains also a time stamp (time-2) and a corresponding value (state-2). I would like to compare the "state" variables at every moment in time to find the maximum difference between both. However, since the time stamps are not synchronized between both data sets I cannot simply compare line 1 with line 1 etc. The data sets can be read as follows: data set 1 has 1 state at time 6.164012 seconds and after 2 states after 6.290051 seconds. Data set 2 has 1 state after 6.164015 seconds and 2 states after 6.290055 seconds.
EDIT2: You can think of both data sets as step functions (x-axis is the time, y-axis the state variable). Then you end up with something like this:
^
| +---------+
| | | +---+
| +--+ +---+ | | |
| | | | +-+ + ... f1
|--------+ +-------- ... f2
+------------------------------->
And I want to know at which time (x value) the difference between f1 and f2 (y_1 - y_2) is at its peak. In this case I don't have "functions" but two data sets belonging to the same experiment being run with different parameters.