# Convert stochastic matrix to act on diagonal matrices

Given a stochastic matrix $$Q$$ that converts probability distributions $$p$$ to other probability distributions, $$q = Qp$$, how do I adapt this to work for diagonal matrices?

To be more specific, I have probability vectors $$p$$ of size $$N\times 1$$ and the stochastic matrix of $$Q$$ of size $$M\times N$$ acts on it to produce an output probability vector $$q$$ of size $$M\times 1$$. Now, I am given instead the input probability vector as an $$N\times N$$ diagonal matrix and I would like my output to be the $$M\times M$$ diagonal matrix corresponding to $$q$$.

I do not want to convert the $$N\times N$$ diagonal matrix into a vector and simply apply the original stochastic matrix and then transform the output $$M\times 1$$ vector into a $$M\times M$$ diagonal matrix.

Is there a direct way to transform $$Q$$ to achieve this?

EDIT: As pointed out by Eric, it is impossible if I insist that the transformed $$Q$$ acts in the same way as $$Q$$. But assuming I will be doing $$\hat{Q}\hat{p}\hat{Q}^T$$, (where $$\hat{p} = diag(p)$$) what is the correct way of getting $$\hat{Q}$$ from $$Q$$?

Minimal example: Let $$p = \begin{pmatrix}p_1\\p_2 \end{pmatrix}$$ and $$Q = \begin{pmatrix}q_1 & q_2\\q_3 & q_4\end{pmatrix}$$. Then $$q = Qp = \begin{pmatrix}q_1 & q_2\\q_3 & q_4\end{pmatrix} \cdot \begin{pmatrix}p_1\\p_2 \end{pmatrix} = \begin{pmatrix}q_1 p_1 + q_2 p_2 \\ q_3 p_1 + q_4 p_2 \end{pmatrix} \text{.}$$
You want a $$\hat{Q} = \begin{pmatrix}a & b \\ c & d \end{pmatrix}$$ taking $$\hat{p} = \begin{pmatrix}p_1 & 0 \\ 0 & p_2\end{pmatrix}$$ to $$\hat{q} = \begin{pmatrix}q_1 p_1 + q_2 p_2 & 0 \\ 0 & q_3 p_1 + q_4 p_2 \end{pmatrix}$$. But, $$\hat{Q}\hat{p} = \begin{pmatrix}a & b \\ c & d \end{pmatrix} \cdot \begin{pmatrix}p_1 & 0 \\ 0 & p_2\end{pmatrix} = \begin{pmatrix}a p_1 & b p_2 \\ c p_1 & d p_2 \end{pmatrix} \text{,}$$ requiring $$b = c = 0$$, and leaving no possible assignments for $$a$$ and $$d$$. Also, \begin{align*} \hat{Q}\hat{p}\hat{Q}^T &= \begin{pmatrix}a & b \\ c & d \end{pmatrix} \cdot \begin{pmatrix}p_1 & 0 \\ 0 & p_2\end{pmatrix} \cdot \begin{pmatrix}a & c \\ b & d \end{pmatrix} \\ &= \begin{pmatrix}a p_1 & b p_2 \\ c p_1 & d p_2 \end{pmatrix} \cdot \begin{pmatrix}a & c \\ b & d \end{pmatrix} \\ &= \begin{pmatrix}a^2 p_1 + b^2 p_2 & a c p_1 + b d p_2 \\ a c p_1 + b d p_2 & c^2 p_1 + d^2 p_2 \end{pmatrix} \text{,} \end{align*} requiring $$ac = bd = 0$$ to get the off-diagonals. For $$ac = 0$$, either $$a^2 = q_1 = 0$$ or $$c^2 = q_3 = 0$$ (or both). For $$bd = 0$$, either $$b^2 = q_2 = 0$$ or $$d^2 = q_4 = 0$$. Consequently, for this to have any chance of working, $$Q$$ is half zeroes.
• Nothing in the question suggests that you intend to use $\hat{Q}$ differently than you use $Q$. May 11, 2019 at 16:02
• Sorry for the lack of clarity- I will edit that. But does allowing a sandwich $\hat{Q}\hat{p}\hat{Q}^T$ allow what I am trying to do? May 11, 2019 at 16:03