Homodyne measurement

Hi all,

I have a question regarding the Homodyne measurement, particularly measurement of the X quadrature. What exactly I get as an output when I perform MeasureX? When we measure some operator using one shot, the current state collapses to one of the eigenstates giving as the output eigenvalue corresponding to that eigenstate. Using many shots entire spectrum of the eigenstates is probed, giving as the output probability distribution of each of the eigenstates. So, what exactly is the meaning of the real number that is produced as the output when MeasureX is performed. Thanks in advance.

hi @Ljubomir_Budinski — Welcome to the forum! When you use MeasureX, you measure a quadrature of the field. So if you write the eigenvalue relation

\hat{x} |x \rangle = x |x \rangle

for the (continous-spectrum) position operator \hat{x}, then when you MeasureX on some quantum state | \psi \rangle you sample a random variable with probability mass function

\text{pmf}(x) = |\langle x| \psi\rangle|^2

This can be interpreted as, "the probability of obtaining a value between x and x+dx is \Pr(x,x+dx) = \text{pmf}(x) dx, "

Keep in mind that as it is common in quantum optics, when one measures a mode of light this mode is traced out. Thus after you measure a mode (in the quadrature or in the Fock basis) the mode that was measured simply ceases to exist.

Hope this helps,


1 Like

Hi @Nicolas_Quesada

Thank you for the explanation. This is exactly what I have expecting. Thanκ you for the elaboration and confirmation that I’m on the right track. If upon measuring measureX quadrature of some state | \psi \rangle some random variable is obtained, what exactly means the output of 3.04173042 that I’m constantly getting from this piece of code

prog = sf.Program(1)
eng = sf.Engine("fock", backend_options={"cutoff_dim": 20})

with prog.context as q:
    Fock(0)     | (q[0])
    Dgate(1.0)  |  q[0]
    MeasureX    | q[0]

results = eng.run(prog)

If the random value should be obtained, why I’m getting the same value for each try. Thank you in advance.

Best regards.

Hi @Ljubomir_Budinski — In your circuit you are preparing the zeroth Fock state (vacuum) and then displacing by \alpha = \frac{1}{\sqrt{2 \hbar} }(x+i p) = 1 . Since the default value of \hbar is 2 that means you prepared a coherent state centered around (x=2, p=0) in phase space.
This coherent state will have a probability distribution centered around x=2 with variance equal to 1.
Thus you sampled a standard normal distribution with mean 2 and got the value 3.04… .
If you generated many X-samples and histogrammed them you would see that they start to clump like the usual bell shape with mean 2 and variance 1 for this circuit.
Obviously, like any statistical experiment you cannot attach a lot of meaning to a single sample, to get understanding you will need to do statistics over many samples.

Hope this helps,


1 Like

Hi @Nicolas_Quesada

Thank you very much for the explanation. Honestly, it is much clearer now. I was puzzled by the fact that every time I repeat the try (program) the same value of 3.04 is obtained. But, as you said, this is just a sample pulled out from normal distribution. If we perform many of this experiments we will then be able to build entire distribution. Thanks again for the help. You are very kind.

Best regards,



@Ljubomir_Budinski glad you got it working :slight_smile: Feel free to open another thread if you have any more questions!

1 Like