Average photon number of two modes?


I was wondering if it was possible to obtain the mean photon number of two qumodes?

I know its possible to get the mean photon number of one mode [0] using:

n0 = state.mean_photon(0)

and another mode [1]:

n1 = state.mean_photon(1)

But say I wanted the mean photon number of modes 0 and 1 together, as in:

n0n1 = state.mean_photon(0, 1)

So I obtain the mean of both modes?

Hi @Aimon_Qazi, welcome to the forum!

If you want to use mean_photon you can only use it for a single mode. I believe that unfortunately there isn’t a function that does what you want.

One workaround is that you could run the simulation, get the samples, and calculate the mean photon number from those.

I hope this helps!

Thank you for taking the time to answer.

Could you maybe elaborate on how I would get the mean of two modes please? Are you suggesting there is a way to get the samples of mode 0 and mode 1, to allow me to multiply them and then get the average?

Hi @Aimon_Qazi!

You can use result.samples to get the samples for all modes at the same time. This will give you an array with shape (shots, modes). You can then manually calculate the mean for each mode.

Let me know if this helps!