# Mathematically modeling two frequencies

So i'd like to model a recurring event (I don't think this is a statistics problem though) that is affected by another event with a different frequency. Say event A has a slower BASE frequency (about every 2.7 seconds), and event B has a higher frequency (about every 1.6 seconds). When the second event occurs, it has a chance to accelerate the next A event, but only if the next event A is more than 20% away from occurring again.

For example, the first event that occurs with the arbitrary numbers we have here would be a B even at time t = 1.6. Because the next event is still 1.1 seconds away, which is more than 2.7*.2, the next event A is accelerated by some time in seconds, lets say 1.5 seconds. If the added time is greater than the remaining time, it just instantly triggers the next event A and it's timer until the next event is reset.

What i'm trying to find is the final resulting interval between A events on average.

I'm not really sure how best to explain it, so if more clarification is needed let me know. It feels like it would be some type of wave sum problem, but I'm not sure how to set it up with all these variables involved.

• This is (sort of) a statistical problem (unless the frequencies are rational) but there are, in general, no good ways to perform these kinds of calculations analytically (I am having a hard time understanding your particular scenario, so I am not going to say anything about it). The way one would approach this numerically is with a discrete event simulator. Look at en.wikipedia.org/wiki/Discrete_event_simulation for a coarse idea of how this kind of software works. You can write simple discrete event simulations yourself or you can use a number of open source or commercial tools. – CuriousOne Jun 4 '15 at 8:17

This situation can be solved exactly, and it will not have any significant statistical behaviour. The point is that once event $B$ triggers event $A$ for the first time, they become synchronized and they enter a completely periodic loop, whose period is the separation between synchronization events, and is completely determined.
Suppose that timer $A$ clicks with period $T_1$ and timer $B$ with period $T_2$, and that if timer $B$ clicks within the last $r=20\%$ of an $A$ cycle, the timers will synchronize. Then the minimal $n$ for which $$\left\lfloor n\frac{T_2}{T_1}\right\rfloor>1-r$$ will be the number of $B$ periods elapsed between every two contiguous synchronization events. (Here $\lfloor\cdot\rfloor$ is the floor function).This only has a nice analytic expression when $T_1<rT_2$ (i.e. it's not possible for timer $B$ to completely sidestep a 'sensitivity' period of timer $A$), in which case $$n=\lfloor (1-r)T_2/T_1\rfloor.$$