Stationary distribution in continuous-time Markov chain

Consider a barbershop with one barber who can cut hair at rate 4 (people per hour), and three waiting chairs. Customers arrive at rate 5 per hour. Customers who arrive to a fully occupied shop leave without being served. Find the stationary distribution for the number of customers in the shop.

So I need to find the solution for $$\pi Q=0$$ or similarly solve the balance condition equations $$\pi(k)q(k,j)=\pi(j)q(j,k)\space\forall j\neq k,$$ where $Q$ is the transition rates matrix. If exists three waitings chairs plus one customers already cutting, then the state space is $S=(0,1,2,3,4)$.

I'm not so sure on how to write the matrix, what I did is $$Q=\begin{bmatrix}-5&5&0&0&0\\4&-9&5&0&0\\0&4&-9&5&0\\0&0&4&-9&5\\0&0&0&4&0\end{bmatrix}$$

where $Q(i,i)=-\sum_{i\neq j}q(i,j)$.

You have one simple error in your matrix: the last diagonal entry should be $-4$. Everything else seems fine.

Anyway, you can try to use the detailed balance equations. In particular consider the case where $k,j$ differ only by $1$, since these are actually the only possible transitions. From this you get four linear equations:

$$5\pi(0)=4\pi(1) \\ 5\pi(1)=4\pi(2) \\ 5\pi(2)=4\pi(3) \\ 5\pi(3)=4\pi(4). \\$$

You can solve these, obtaining a solution involving a free parameter, and then normalize. A convenient choice of the free parameter will turn out to be $\pi(4)$ or $\pi(0)$, since your system can be solved by back-substitution given a value of either of these. You should double-check that this worked, since you didn't know in advance that your system would be in detailed balance.

Proceeding directly by finding the normalized left eigenvector with eigenvalue zero would be just slightly more complicated (since three of the equations would have three variables).

• It seems to be easier to solve the detailed balanced equation than solve the $\pi Q=0$. The state space is $S=(0,1,2,3,4)$, doesn't matter which values I choice for $i$ and $k$, since they are different, I will always get the same stationary distribution in the end? Commented Aug 9, 2015 at 19:10
• @JohnSheridan To find the equilibrium distribution by the detailed balance approach, in principle you have to check all ${5 \choose 2}=10$ possible pairings of states. But you get most of these conditions for free, since most of the $q(i,j)$ are zero.
– Ian
Commented Aug 9, 2015 at 19:12
• @JohnSheridan Also note that the detailed balance approach will not always work, because there are systems which are not in detailed balance. A simple example is given by a deterministic oscillator, i.e. a chain that always goes like $1 \to 2 \to 3 \to \dots \to n \to 1 \to 2 \to \dots$
– Ian
Commented Aug 9, 2015 at 19:16
• But the system of equations, generated by detailed balance approach it is not always possible and determined? Since we can write $\pi(0)+\pi(1)+\dots+\pi(n)=1$ Commented Aug 9, 2015 at 19:27
• @JohnSheridan If you have a chain which is not actually in detailed balance and you try to write down the detailed balance equations for the stationary distribution, the resulting system will always be overdetermined.
– Ian
Commented Aug 9, 2015 at 19:34