# Effective inter-arrival time converge to mean

I am fairly new to statistics and just recently encountered queueing theory.

I have programmed a simulation for a $M/M/1$ queue in which I specify the inter-arrival times and service times. I input say, an exponential distribution with a mean of $1$ for both the inter-arrival and service time.

I also measure for the effective arrival rate, meaning I run for, say, $1000$ time steps and at each time step a random value is drawn from the exponential distribution. I collect these random values in a list and then compute the effective arrival rate, this being the mean of the list. In theory, this value should converge to the mean, yet, in practice I end up with values not so close to the mean.

My question is, how many random values from an exponential distribution should I draw such that the mean of these converges to the mean of the distribution?

## 2 Answers

The exponential distribution with mean $1$ also has standard deviation $1$. If you collect statistics for $1000$ time units, you should get a sample mean of about $1$ with a standard error of about $0.032$. When you say your values are not so close to the mean, how far off are they?

By the way, you should be aware that if both the inter-arrival and the service times have mean $1$, the queue is not stable.

Let $\lambda$ be the interarrival rate and $\mu$ the service rate (so the mean interarrival and service times are $\frac1\lambda$ and $\frac1\mu$, respectively). We can model the $M/M/1$ queue as a continuous-time Markov chain $\{X(t) : t\geqslant 0\}$, where $X(t)$ is the number of entities in the system at time $t$, with state space $\mathbb N\cup\{0\}$ and transition rates $$t_{ij} = \begin{cases} \lambda,& j=i+1\\\mu,& j=i-1.\end{cases}$$ To compute the stationary distribution, i.e. $\pi_i := \lim_{t\to\infty}\mathbb P(X(t)=i)$ we have the flow balance equations

$$\lambda\pi_i = \mu\pi_{i+1},\quad i=0,1,2,\ldots$$ This implies that $\pi_{i+1} = \frac\lambda\mu\pi_i$ and by induction, $$\pi_i = \left(\frac\lambda\mu\right)^i\pi_0.$$ Since $$\sum_{i=0}^\infty \pi_i = 1,$$ it follows that $$1=\sum_{i=0}^\infty\left(\frac\lambda\mu\right)^i\pi_0 = \frac1{1-\frac\lambda\mu}\pi_0$$ and $$\pi_0 = 1-\frac\lambda\mu.$$ Let $\rho = \frac\lambda\mu$. Then the stationary distribution is $$\pi_i = (1-\rho)\rho^i,\quad i=0,1,2,\ldots.$$ Note that this only holds when $\lambda<\mu$. Otherwise, the geometric series above would not converge, and the system is unstable, as @BrianTung pointed out.