sf.utils.all_fock_probs_pnr

all_fock_probs_pnr(photon_number_samples)[source]

The Fock state probabilities for the specified modes obtained from PNR samples.

Measured modes that are not specified are traced over. If either all the modes or no modes were specified, the marginal probabilities are returned.

The Fock basis cutoff truncation is determined by the maximum Fock state with a non-zero probability.

Example:

>>> samples = np.array([[2, 0], [2, 2], [2, 0], [0, 0]])
>>> probs = all_fock_probs_pnr(samples)

2 out of 4 shots had the (2, 0) outcome, that is \(|\braketD{2,0}{\psi}|^2=0.5\). We can check if the probability for this state is correct by indexing into probs:

>>> probs[(2, 0)]
0.5

We can further check the entire array of probabilities:

>>> probs
[[0.25 0.   0.  ]
[0.   0.   0.  ]
[0.5  0.   0.25]]
Parameters

photon_number_samples (array) – the photon number samples with a shape of (shots, modes)

Returns

array of dimension \(\underbrace{D\times D\times D\cdots\times D}_{\text{num modes}}\) containing the Fock state probabilities, where \(D\) is the Fock basis cutoff truncation

Return type

array