I have the data below. I would like to sample with equal step size. For simplicity lets try unit step size. Here is the desired result. Find the first time exceed the unit time step, and take lower ones second entry. {{1,0},{2,0},{3,3},{4,10},{5,17},{6,27},{7,43},{8,63}}
and so on.
This suppose to work but it does not.
iFun = Interpolation[data, InterpolationOrder -> 0];
τ = 1;
range = Range[0, data[[-1, 1]], τ];
data2 = Transpose@{range, iFun@range};
SeedRandom@2
A = 30;
\[Beta] = 0.05;
{a, b} = {72, 1/12};
X = x = 0;
currentTime = 0;
stackTime = {};
data = Prepend[Join @@ Last@Reap@Do[
a1 = A ;
a2 = \[Beta] X;
a0 = Total@{a1, a2};
reactionVec = 1/a0 Accumulate@{a1, a2};
reaction =
First@FirstPosition[reactionVec - RandomReal[], _?Positive];
tDelay = RandomVariate@GammaDistribution[a, b];
tWait = RandomVariate@ExponentialDistribution[a0];
currentTime = currentTime + tWait;
stackTime = Sort@stackTime;
minStack = Min[stackTime];
Which[
currentTime < minStack,
Which[
reaction == 1, {Sow@{currentTime, X},
AppendTo[stackTime, currentTime + tDelay]},
reaction == 2, {Sow@{currentTime, X -= 1}}],
minStack < currentTime,
{Sow@{minStack, X += 1}, currentTime = minStack,
stackTime = Rest@stackTime} ]
, 1000], {0, x}];