# Details for implementing the measurement of a simulation

I am trying to work out how to program a simulation of a quantum computer program. I think I understand all the steps, of implementing a simulation, except the simulation of the measurement. I will use 2 qubit states to illustrate; though the illustration below extends in an obvious way to n qubits. Suppose after we are up to the state just before measurement it is

$$a_0|00\rangle+a_1|01\rangle+a_2|10\rangle+a_3|11\rangle$$

Suppose there exist a unique maximum from the real numbers $$a_0,a_1,a_2,a_3$$ let refer to this as m; and that the sum of squares of the 4 amplitudes sum to 1. and we want to know what is the most likely state that will be measured.

A) Is the most likely state to be measured the one with maximum squared amplitude of $$a_0,a_1,a_2,a_3$$ in other words, the most likely state has a probability $$m^2$$ of being measured -for example, out of 100 repeated measurements $$(100*(m^2))$$, to the nearest integer, will be the likely state.

or

B) Is the most likely state to be measured the one that has the highest ratios regarding the amplitudes, compared to every other state, the ratio measures how many times more likely one state is to be measured when compared to another state,suppose that $$a_3$$ is near to one, and $$a_0,a_1,a_3$$ are near to zero then computing the absolute values of

$$|a_3/a_2|,|a_3/a_1|, |a_3/a_0|$$ I assume, not sure but assuming here, will give the largest 3 values when compared to any of the values in the two lists of amplitude ratios

$$|a_2/a_3| ,|a_2/a_1|, |a_2/a_0|$$

or

$$|a_1/a_2|,|a_1/a_0|, |a_1/a_3|$$

therefore $$a_3$$ is most likely to measured and suppose $$a_3/a_2, a_3/a_1, a_3/a_0$$ are all largest than some integer I then if I is large enough for the simulation then we can ignore how many times, referred to as T, we measure the state because we can conclude $$a_3$$ is measured every time.

So is the answer A or B?

A pure state $$|\psi \rangle = \sum c_i |e_i\rangle$$ is a superposition state of the states $$|\psi_\rangle$$ and the $$|c_i|^2$$ is probability that one would observe $$|\psi_i\rangle$$ when measured.
For example: Suppose we have $$|\psi \rangle = \dfrac{3}{5}|0\rangle + \dfrac{4}{5}|1\rangle$$
Then this state $$|\psi\rangle$$ will be measured as $$|0\rangle$$ in the $$Z$$ basis (computational basis, the usual basis one deals with when thinking about quantum computing) with probability $$\bigg| \dfrac{3}{5} \bigg|^2 = \dfrac{9}{25}$$. And similarly, it has probability $$\bigg| \dfrac{4}{5} \bigg|^2 = \dfrac{16}{25}$$ being measured as $$|1\rangle$$. Note that $$\dfrac{9}{25} + \dfrac{16}{25} = 1$$. This makes sense because there are only 2 possible states ($$|0\rangle$$ or $$|1\rangle$$ ) that you can measure, so their probability must sum up to $$1$$. In this case, we see that we will see the state $$|\psi \rangle$$ collapsed onto the state $$|1\rangle$$ more often than it will collapse to the state $$|0\rangle$$. However, there is no pattern to this collapse. That is, you don't expect them to alternate, $$|0\rangle$$ then $$|1\rangle$$ then $$|0\rangle$$ of that sort. It will be random. But after doing maybe 1000 experiment, you find that you recorded 355 times that the state $$|\psi \rangle$$ collapse to the state $$|0\rangle$$ and the other 645 it has collapsed to the state $$|1\rangle$$.
Hence giving $$|\psi \rangle = \sum c_i |e_i\rangle$$, the largest $$|c_i|^2$$ value do tells us that we will observe that particular $$|\psi_i\rangle$$ state more than the other states in our experiments.
Now, can we look at the absolute ratio of these two states $$( |0\rangle$$ and $$|1\rangle )$$ and say which one it will collapse to more often? Yes, at least mathematically. And you can see here $$\bigg| \dfrac{4}{5}/\dfrac{3}{5} \bigg| > \bigg| \dfrac{3}{5}/\dfrac{4}{5} \bigg|$$. But we must remember that we in general do not have access to the superposition of the state of the qubit! This superposition is only know by the qubit itself. That is, giving a qubit in the state $$|\psi \rangle = \alpha|0\rangle + \beta|1\rangle$$ we would never know what $$\alpha$$ or $$\beta$$ is. And to retrieve this information of $$|\alpha|^2$$ and $$|\beta|^2$$, we do many many measurements to get a statistical distribution. This is how quantum mechanics was postulate. It is not a problem of engineering.