Is your queue free one tenth of the time? Expect to work ten tasks between breaks.

If I have 1 worker dedicated to a stream of independently distributed tasks each with fixed unit time, and this stream averages $ y \in (0,1) $ new tasks per unit time, then the distribution for freeing the queue after exactly $ x $ units of work is

$$ M(x,y) = \frac{ e^{- x y} (x y)^{x-1}}{x!} $$

Numerical summation of $ \sum_{x=1}^{\infty} M(x,y) = 1 $ for any $ y \in ( 0, 1) $, which demonstrates a valid distribution. Performing a similar numerical summation in this same range to find the mean also converges:

$$ E(X) = \sum_{x=1}^{\infty} x M(x,y) \approx \frac{1}{1-y} $$

So, quite simply, by this distribution, if my minion spends 1/5 of his time with a free queue, then I should expect him to work 5 tasks (on average) before the queue is again free. Also, by the exponential distribution, having 4/5 of his time busy, I should expect a free queue to last about 5/4 task units.

Fixed task lengths may make this result seem trivial, so I could assign an exponential random variable to the time on each task, with unit mean. Keeping the mean arrival rate of $ \frac{1}{y} $ will leave $ y \in ( 0, 1) $ time free on average just like $ M(x, y) $. Specifically, I have the following:

Time to next decrement from queue (non-empty) has a distribution

$$ ~ Exp(X,1) = e^{-x} $$

Time to next increment to queue has a distribution

$$ ~ Exp(x,y) = y e^{- x y} $$

Because decrement and increment is memory-less, I can quickly explore the function of a working queue. Before I begin, at $ x = 0 $, I have an empty queue (0-job state). There is no chance of decrement, so work start is predicted by $ ~ Exp(x,y) $. At that moment the queue will be active on the first job; I'll call this the 1-job state. The 1-job state lasts until the job finishes, or a second job is queued. If a second job is queued, I have the 2-job state, which this will last until either a job finishes (returning to the 1-job state), or else a third job will be queued (3-job state). And so on.

Will this FRIFRO (First random-in, first random-out) look like the continuous variant of the next $ M $ distribution? I'm not expecting any surprises but I'm still working on it.