Let's say you can simulate a discrete uniform distribution $\{0,1\}$ (like a coin toss). With $P\{1\} = P\{2\} = 0.5$.
Now we would like to simulate a distribution $S = \{1,2,3\}$ with $P_Z\{1\} = 0.2$ and $P_Z\{2\} = P_Z\{3\} = 0.4$.
How can you calculate the transition matrix $M$ which has $P_Z$ as its stationary distribution? This example is taken from the Wikipedia Article "MCMC-Verfahren" (german Wikipedia) https://de.wikipedia.org/wiki/MCMC-Verfahren.
I dont understand how the transition matrix $M$ is formed. Which rules are applied to calculate the transition probabilites $M_{ij}$?
The solution is: $M = \begin{bmatrix}0&1&0\\0&0.5&0.5 \\ 0.5&0&0.5\end{bmatrix}$
Any help is appreciated.
There are many answers on this site dealing with Markov chain Monte Carlo, and a rigorous introduction can be found in many textbooks, but I guess that you are looking for some background context.
There is, in general, considerable choice of transition matrices to generate a desired distribution. So there is no unique prescription, but the matrix $M$ must satisfy some conditions.
I should mention the Metropolis-Hastings algorithm for constructing $M$, which is very useful when the state space is very large, and when the distribution probabilities are only known up to some common normalizing factor (which may be impractical to calculate). This is a common situation in physics simulations. Then the off-diagonal elements $M_{ij}$ are expressed as a product of two terms: a proposal probability $\alpha_{ij}$, and an acceptance probability $A_{ij}$. The elements of $\alpha$ are usually chosen to be nonzero for pairs of states which are "nearby" (in a sense connected with the physics); they are independent of $P_Z$, and typically $\alpha_{ij}=\alpha_{ji}$. The acceptance probability $A_{ij}$ is given by a formula involving the ratio $P_Z\{i\}/P_Z\{j\}$, and so that $A_{ij}/A_{ji}$ satisfies detailed balance. The diagonal elements of $M$ are fixed by condition 1 above. More details are easy to come by, elsewhere.
Lastly, there is some scope for discussing whether one transition matrix is "better" than another, for example in the sense of converging more quickly towards the stationary distribution. Again, I don't think it's appropriate here to go into details, but this will be related to the subsidiary eigenvalues of $M$, particularly the second largest (the largest being $1$).