Quantum algorithms

This submodule provides access to various utility functions that act on Gaussian quantum states.

For more details on how the hafnian relates to various properties of Gaussian quantum states, see:

Fock states and tensors

pure_state_amplitude(mu, cov, i[, …])

Returns the \(\langle i | \psi\rangle\) element of the state ket of a Gaussian state defined by covariance matrix cov.

state_vector(mu, cov[, post_select, …])

Returns the state vector of a (PNR post-selected) Gaussian state.

density_matrix_element(mu, cov, i, j[, …])

Returns the \(\langle i | \rho | j \rangle\) element of the density matrix of a Gaussian state defined by covariance matrix cov.

density_matrix(mu, cov[, post_select, …])

Returns the density matrix of a (PNR post-selected) Gaussian state.

fock_tensor(S, alpha, cutoff[, choi_r, …])

Calculates the Fock representation of a Gaussian unitary parametrized by the symplectic matrix S and the displacements alpha up to cutoff in Fock space.

probabilities(mu, cov, cutoff[, hbar, rtol, …])

Generate the Fock space probabilities of a Gaussian state up to a Fock space cutoff.

update_probabilities_with_loss(etas, probs)

Given a list of transmissivities a tensor of probabilitites, calculate an updated tensor of probabilities after loss is applied.

update_probabilities_with_noise(probs_noise, …)

Given a list of noise probability distributions for each of the modes and a tensor of probabilitites, calculate an updated tensor of probabilities after noise is applied.

fidelity(mu1, cov1, mu2, cov2[, hbar, rtol, …])

Calculates the fidelity between two Gaussian quantum states.

Details

pure_state_amplitude(mu, cov, i, include_prefactor=True, tol=1e-10, hbar=2, check_purity=True)[source]

Returns the \(\langle i | \psi\rangle\) element of the state ket of a Gaussian state defined by covariance matrix cov.

Parameters
  • mu (array) – length-\(2N\) quadrature displacement vector

  • cov (array) – length-\(2N\) covariance matrix

  • i (list) – list of amplitude elements

  • include_prefactor (bool) – if True, the prefactor is automatically calculated used to scale the result.

  • tol (float) – tolerance for determining if displacement is negligible

  • hbar (float) – the value of \(\hbar\) in the commutation relation \([\x,\p]=i\hbar\).

  • check_purity (bool) – if True, the purity of the Gaussian state is checked before calculating the state vector.

Returns

the pure state amplitude

Return type

complex

state_vector(mu, cov, post_select=None, normalize=False, cutoff=5, hbar=2, check_purity=True, **kwargs)[source]

Returns the state vector of a (PNR post-selected) Gaussian state.

The resulting density matrix will have shape

\[\underbrace{D\times D \times \cdots \times D}_M\]

where \(D\) is the Fock space cutoff, and \(M\) is the number of non post-selected modes, i.e. M = len(mu)//2 - len(post_select).

If post_select is None then the density matrix elements are calculated using the multidimensional Hermite polynomials which provide a significantly faster evaluation.

Parameters
  • mu (array) – length-\(2N\) means vector in xp-ordering

  • cov (array) – \(2N\times 2N\) covariance matrix in xp-ordering

  • post_select (dict) – dictionary containing the post-selected modes, of the form {mode: value}.

  • normalize (bool) – If True, a post-selected density matrix is re-normalized.

  • cutoff (dim) – the final length (i.e., Hilbert space dimension) of each mode in the density matrix.

  • hbar (float) – the value of \(\hbar\) in the commutation relation \([\x,\p]=i\hbar\).

  • check_purity (bool) – if True, the purity of the Gaussian state is checked before calculating the state vector.

Keyword Arguments

choi_r (float or None) – Value of the two-mode squeezing parameter used in Choi-Jamiolkoski trick in fock_tensor(). This keyword argument should only be used when state_vector is called by fock_tensor().

Returns

the state vector of the Gaussian state

Return type

np.array[complex]

density_matrix_element(mu, cov, i, j, include_prefactor=True, tol=1e-10, hbar=2)[source]

Returns the \(\langle i | \rho | j \rangle\) element of the density matrix of a Gaussian state defined by covariance matrix cov.

Parameters
  • mu (array) – length-\(2N\) quadrature displacement vector

  • cov (array) – length-\(2N\) covariance matrix

  • i (list) – list of density matrix rows

  • j (list) – list of density matrix columns

  • include_prefactor (bool) – if True, the prefactor is automatically calculated used to scale the result.

  • tol (float) – tolerance for determining if displacement is negligible

  • hbar (float) – the value of \(\hbar\) in the commutation relation \([\x,\p]=i\hbar\).

Returns

the density matrix element

Return type

complex

density_matrix(mu, cov, post_select=None, normalize=False, cutoff=5, hbar=2)[source]

Returns the density matrix of a (PNR post-selected) Gaussian state.

The resulting density matrix will have shape

\[\underbrace{D\times D \times \cdots \times D}_{2M}\]

where \(D\) is the Fock space cutoff, and \(M\) is the number of non post-selected modes, i.e. M = len(mu)//2 - len(post_select).

Note that we use the Strawberry Fields convention for indexing the density matrix; the first two dimensions correspond to subsystem 1, the second two dimensions correspond to subsystem 2, etc. If post_select is None then the density matrix elements are calculated using the multidimensional Hermite polynomials which provide a significantly faster evaluation.

Parameters
  • mu (array) – length-\(2N\) means vector in xp-ordering

  • cov (array) – \(2N\times 2N\) covariance matrix in xp-ordering

  • post_select (dict) – dictionary containing the post-selected modes, of the form {mode: value}. If post_select is None the whole non post-selected density matrix is calculated directly using (multidimensional) Hermite polynomials, which is significantly faster than calculating one hafnian at a time.

  • normalize (bool) – If True, a post-selected density matrix is re-normalized.

  • cutoff (dim) – the final length (i.e., Hilbert space dimension) of each mode in the density matrix.

  • hbar (float) – the value of \(\hbar\) in the commutation relation \([\x,\p]=i\hbar\).

Returns

the density matrix of the Gaussian state

Return type

np.array[complex]

fock_tensor(S, alpha, cutoff, choi_r=0.881373587019543, check_symplectic=True, sf_order=False, rtol=1e-05, atol=1e-08)[source]

Calculates the Fock representation of a Gaussian unitary parametrized by the symplectic matrix S and the displacements alpha up to cutoff in Fock space.

Parameters
  • S (array) – symplectic matrix

  • alpha (array) – complex vector of displacements

  • cutoff (int) – cutoff in Fock space

  • choi_r (float) – squeezing parameter used for the Choi expansion

  • check_symplectic (boolean) – checks whether the input matrix is symplectic

  • sf_order (boolean) – reshapes the tensor so that it follows the sf ordering of indices

  • rtol (float) – the relative tolerance parameter used in np.allclose

  • atol (float) – the absolute tolerance parameter used in np.allclose

Returns

Tensor containing the Fock representation of the Gaussian unitary

Return type

(array)

probabilities(mu, cov, cutoff, hbar=2.0, rtol=1e-05, atol=1e-08)[source]

Generate the Fock space probabilities of a Gaussian state up to a Fock space cutoff.

Parameters
  • mu (array) – vector of means of length 2*n_modes

  • cov (array) – covariance matrix of shape [2*n_modes, 2*n_modes]

  • cutoff (int) – cutoff in Fock space

  • hbar (float) – value of \(\hbar\) in the commutation relation :math;`[hat{x}, hat{p}]=ihbar`

  • rtol (float) – the relative tolerance parameter used in np.allclose

  • atol (float) – the absolute tolerance parameter used in np.allclose

Returns

Fock space probabilities up to cutoff. The shape of this tensor is [cutoff]*num_modes.

Return type

(array)

update_probabilities_with_loss(etas, probs)[source]

Given a list of transmissivities a tensor of probabilitites, calculate an updated tensor of probabilities after loss is applied.

Parameters
  • etas (list) – List of transmissitivities describing the loss in each of the modes

  • probs (array) – Array of probabilitites in the different modes

Returns

List of loss-updated probabilities with the same shape as probs.

Return type

array

update_probabilities_with_noise(probs_noise, probs)[source]

Given a list of noise probability distributions for each of the modes and a tensor of probabilitites, calculate an updated tensor of probabilities after noise is applied.

Parameters
  • probs_noise (list) – List of probability distributions describing the noise in each of the modes

  • probs (array) – Array of probabilitites in the different modes

Returns

List of noise-updated probabilities with the same shape as probs.

Return type

array

Utility functions

reduced_gaussian(mu, cov, modes)

Returns the vector of means and the covariance matrix of the specified modes.

Xmat(N)

Returns the matrix \(X_n = \begin{bmatrix}0 & I_n\\ I_n & 0\end{bmatrix}\)

Qmat(cov[, hbar])

Returns the \(Q\) Husimi matrix of the Gaussian state.

Covmat(Q[, hbar])

Returns the Wigner covariance matrix in the \(xp\)-ordering of the Gaussian state.

Amat(cov[, hbar, cov_is_qmat])

Returns the \(A\) matrix of the Gaussian state whose hafnian gives the photon number probabilities.

Beta(mu[, hbar])

Returns the vector of complex displacements and conjugate displacements.

Means(beta[, hbar])

Returns the vector of real quadrature displacements.

prefactor(mu, cov[, hbar])

Returns the prefactor.

find_scaling_adjacency_matrix(A, n_mean)

Returns the scaling parameter by which the adjacency matrix A should be rescaled so that the Gaussian state that endodes it has a total mean photon number n_mean.

mean_number_of_clicks(A)

Given an adjacency matrix this function calculates the mean number of clicks.

find_scaling_adjacency_matrix_torontonian(A, …)

Returns the scaling parameter by which the adjacency matrix A should be rescaled so that the Gaussian state that encodes it has give a mean number of clicks equal to c_mean when measured with threshold detectors.

gen_Qmat_from_graph(A, n_mean)

Returns the Qmat xp-covariance matrix associated to a graph with adjacency matrix \(A\) and with mean photon number \(n_{mean}\).

photon_number_mean(mu, cov, j[, hbar])

Calculate the mean photon number of mode j of a Gaussian state.

photon_number_mean_vector(mu, cov[, hbar])

Calculate the mean photon number of each of the modes in a Gaussian state

photon_number_covar(mu, cov, j, k[, hbar])

Calculate the variance/covariance of the photon number distribution of a Gaussian state.

photon_number_covmat(mu, cov[, hbar])

Calculate the covariance matrix of the photon number distribution of a Gaussian state.

is_valid_cov(cov[, hbar, rtol, atol])

Checks if the covariance matrix is a valid quantum covariance matrix.

is_pure_cov(cov[, hbar, rtol, atol])

Checks if the covariance matrix is a valid quantum covariance matrix that corresponds to a quantum pure state

is_classical_cov(cov[, hbar, atol])

Checks if the covariance matrix can be efficiently sampled.

total_photon_num_dist_pure_state(cov[, …])

Calculates the total photon number distribution of a pure state with zero mean.

gen_single_mode_dist(s[, cutoff, N])

Generate the photon number distribution of \(N\) identical single mode squeezed states.

gen_multi_mode_dist(s[, cutoff, padding_factor])

Generates the total photon number distribution of single mode squeezed states with different squeezing values.

Details

Amat(cov, hbar=2, cov_is_qmat=False)[source]

Returns the \(A\) matrix of the Gaussian state whose hafnian gives the photon number probabilities.

Parameters
  • cov (array) – \(2N\times 2N\) covariance matrix

  • hbar (float) – the value of \(\hbar\) in the commutation relation \([\x,\p]=i\hbar\).

  • cov_is_qmat (bool) – if True, it is assumed that cov is in fact the Q matrix.

Returns

the \(A\) matrix.

Return type

array

Beta(mu, hbar=2)[source]

Returns the vector of complex displacements and conjugate displacements.

Parameters
  • mu (array) – length-\(2N\) means vector

  • hbar (float) – the value of \(\hbar\) in the commutation relation \([\x,\p]=i\hbar\).

Returns

the expectation values \([\langle a_1\rangle, \langle a_2\rangle,\dots,\langle a_N\rangle, \langle a^\dagger_1\rangle, \dots, \langle a^\dagger_N\rangle]\)

Return type

array

Covmat(Q, hbar=2)[source]

Returns the Wigner covariance matrix in the \(xp\)-ordering of the Gaussian state. This is the inverse function of Qmat.

Parameters
  • Q (array) – \(2N\times 2N\) Husimi Q matrix

  • hbar (float) – the value of \(\hbar\) in the commutation relation \([\x,\p]=i\hbar\).

Returns

the \(xp\)-ordered covariance matrix in the xp-ordering.

Return type

array

Means(beta, hbar=2)[source]

Returns the vector of real quadrature displacements.

Parameters
  • beta (array) – length-\(2N\) means bivector

  • hbar (float) – the value of \(\hbar\) in the commutation relation \([\x,\p]=i\hbar\).

Returns

the quadrature expectation values \([\langle q_1\rangle, \langle q_2\rangle,\dots,\langle q_N\rangle, \langle p_1\rangle, \dots, \langle p_N\rangle]\)

Return type

array

Qmat(cov, hbar=2)[source]

Returns the \(Q\) Husimi matrix of the Gaussian state.

Parameters
  • cov (array) – \(2N\times 2N xp-\) Wigner covariance matrix

  • hbar (float) – the value of \(\hbar\) in the commutation relation \([\x,\p]=i\hbar\).

Returns

the \(Q\) matrix.

Return type

array

Xmat(N)[source]

Returns the matrix \(X_n = \begin{bmatrix}0 & I_n\\ I_n & 0\end{bmatrix}\)

Parameters

N (int) – positive integer

Returns

\(2N\times 2N\) array

Return type

array

fidelity(mu1, cov1, mu2, cov2, hbar=2, rtol=1e-05, atol=1e-08)[source]

Calculates the fidelity between two Gaussian quantum states.

Note that if the covariance matrices correspond to pure states this function reduces to the modulus square of the overlap of their state vectors. For the derivation see ‘Quantum Fidelity for Arbitrary Gaussian States’, Banchi et al..

Parameters
  • mu1 (array) – vector of means of the first state

  • cov1 (array) – covariance matrix of the first state

  • mu2 (array) – vector of means of the second state

  • cov2 (array) – covariance matrix of the second state

  • hbar (float) – value of hbar in the uncertainty relation

  • rtol (float) – the relative tolerance parameter used in np.allclose

  • atol (float) – the absolute tolerance parameter used in np.allclose

Returns

value of the fidelity between the two states

Return type

(float)

find_scaling_adjacency_matrix(A, n_mean)[source]

Returns the scaling parameter by which the adjacency matrix A should be rescaled so that the Gaussian state that endodes it has a total mean photon number n_mean.

Parameters
  • A (array) – Adjacency matrix

  • n_mean (float) – Mean photon number of the Gaussian state

Returns

Scaling parameter

Return type

float

find_scaling_adjacency_matrix_torontonian(A, c_mean)[source]

Returns the scaling parameter by which the adjacency matrix A should be rescaled so that the Gaussian state that encodes it has give a mean number of clicks equal to c_mean when measured with threshold detectors.

Parameters
  • A (array) – adjacency matrix

  • c_mean (float) – mean photon number of the Gaussian state

Returns

scaling parameter

Return type

float

fock_tensor(S, alpha, cutoff, choi_r=0.881373587019543, check_symplectic=True, sf_order=False, rtol=1e-05, atol=1e-08)[source]

Calculates the Fock representation of a Gaussian unitary parametrized by the symplectic matrix S and the displacements alpha up to cutoff in Fock space.

Parameters
  • S (array) – symplectic matrix

  • alpha (array) – complex vector of displacements

  • cutoff (int) – cutoff in Fock space

  • choi_r (float) – squeezing parameter used for the Choi expansion

  • check_symplectic (boolean) – checks whether the input matrix is symplectic

  • sf_order (boolean) – reshapes the tensor so that it follows the sf ordering of indices

  • rtol (float) – the relative tolerance parameter used in np.allclose

  • atol (float) – the absolute tolerance parameter used in np.allclose

Returns

Tensor containing the Fock representation of the Gaussian unitary

Return type

(array)

gen_Qmat_from_graph(A, n_mean)[source]

Returns the Qmat xp-covariance matrix associated to a graph with adjacency matrix \(A\) and with mean photon number \(n_{mean}\).

Parameters
  • A (array) – a \(N\times N\) np.float64 (symmetric) adjacency matrix

  • n_mean (float) – mean photon number of the Gaussian state

Returns

the \(2N\times 2N\) Q matrix.

Return type

array

gen_multi_mode_dist(s, cutoff=50, padding_factor=2)[source]

Generates the total photon number distribution of single mode squeezed states with different squeezing values.

Parameters
  • s (array) – array of squeezing parameters

  • cutoff (int) – Fock cutoff

Returns

total photon number distribution

Return type

(array[int])

gen_single_mode_dist(s, cutoff=50, N=1)[source]

Generate the photon number distribution of \(N\) identical single mode squeezed states.

Parameters
  • s (float) – squeezing parameter

  • cutoff (int) – Fock cutoff

  • N (float) – number of squeezed states

Returns

Photon number distribution

Return type

(array)

is_classical_cov(cov, hbar=2, atol=1e-08)[source]

Checks if the covariance matrix can be efficiently sampled.

Parameters
  • cov (array) – a covariance matrix

  • hbar (float) – value of hbar in the uncertainty relation

Returns

whether the given covariance matrix corresponds to a classical state

Return type

(bool)

is_pure_cov(cov, hbar=2, rtol=1e-05, atol=1e-08)[source]

Checks if the covariance matrix is a valid quantum covariance matrix that corresponds to a quantum pure state

Parameters
  • cov (array) – a covariance matrix

  • hbar (float) – value of hbar in the uncertainty relation

  • rtol (float) – the relative tolerance parameter used in np.allclose

  • atol (float) – the absolute tolerance parameter used in np.allclose

Returns

whether the given covariance matrix corresponds to a pure state

Return type

(bool)

is_valid_cov(cov, hbar=2, rtol=1e-05, atol=1e-08)[source]

Checks if the covariance matrix is a valid quantum covariance matrix.

Parameters
  • cov (array) – a covariance matrix

  • hbar (float) – value of hbar in the uncertainty relation

  • rtol (float) – the relative tolerance parameter used in np.allclose

  • atol (float) – the absolute tolerance parameter used in np.allclose

Returns

whether the given covariance matrix is a valid covariance matrix

Return type

(bool)

loss_mat(eta, cutoff)[source]

Constructs a binomial loss matrix with transmission eta up to n photons.

Parameters
  • eta (float) – Transmission coefficient. eta=0.0 corresponds to complete loss and eta=1.0 corresponds to no loss.

  • cutoff (int) – cutoff in Fock space.

Returns

\(n\times n\) matrix representing the loss.

Return type

array

mean_number_of_clicks(A)[source]

Given an adjacency matrix this function calculates the mean number of clicks. For this to make sense the user must provide a matrix with singular values less than or equal to one. See Appendix A.3 of <https://arxiv.org/abs/1902.00462>`_ by Banchi et al.

Parameters

A (array) – rescaled adjacency matrix

Returns

mean number of clicks

Return type

float

photon_number_covar(mu, cov, j, k, hbar=2)[source]

Calculate the variance/covariance of the photon number distribution of a Gaussian state.

Implements the covariance matrix of the photon number distribution of a Gaussian state according to the Last two eq. of Part II. in ‘Multidimensional Hermite polynomials and photon distribution for polymode mixed light’, Dodonov et al.

\[\begin{split}\sigma_{n_j n_j} &= \frac{1}{2}\left(T_j^2 - 2d_j - \frac{1}{2}\right) + \left<\mathbf{Q}_j\right>\mathcal{M}_j\left<\mathbf{Q}_j\right>, \\ \sigma_{n_j n_k} &= \frac{1}{2}\mathrm{Tr}\left(\Lambda_j \mathbf{M} \Lambda_k \mathbf{M}\right) + \frac{1}{2}\left<\mathbf{Q}\right>\Lambda_j \mathbf{M} \Lambda_k\left<\mathbf{Q}\right>,\end{split}\]

where \(T_j\) and \(d_j\) are the trace and the determinant of \(2 \times 2\) matrix \(\mathcal{M}_j\) whose elements coincide with the nonzero elements of matrix \(\mathbf{M}_j = \Lambda_j \mathbf{M} \Lambda_k\) while the two-vector \(\mathbf{Q}_j\) has the components \((q_j, p_j)\). \(2N \times 2N\) projector matrix \(\Lambda_j\) has only two nonzero elements: \(\left(\Lambda_j\right)_{jj} = \left(\Lambda_j\right)_{j+N,j+N} = 1\). Note that the convention for mu used here differs from the one used in Dodonov et al., They both provide the same results in this particular case.

Parameters
  • mu (array) – vector of means of the Gaussian state using the ordering \([q_1, q_2, \dots, q_n, p_1, p_2, \dots, p_n]\)

  • cov (array) – the covariance matrix of the Gaussian state

  • j (int) – the j th mode

  • k (int) – the k th mode

  • hbar (float) – the hbar convention used in the commutation relation \([q, p]=i\hbar\)

Returns

the covariance for the photon numbers at modes \(j\) and \(k\).

Return type

float

photon_number_covmat(mu, cov, hbar=2)[source]

Calculate the covariance matrix of the photon number distribution of a Gaussian state.

Parameters
  • mu (array) – vector of means of the Gaussian state using the ordering \([q_1, q_2, \dots, q_n, p_1, p_2, \dots, p_n]\)

  • cov (array) – the covariance matrix of the Gaussian state

  • hbar (float) – the hbar convention used in the commutation relation \([q, p]=i\hbar\)

Returns

the covariance matrix of the photon number distribution

Return type

array

photon_number_mean(mu, cov, j, hbar=2)[source]

Calculate the mean photon number of mode j of a Gaussian state.

Parameters
  • mu (array) – vector of means of the Gaussian state using the ordering \([q_1, q_2, \dots, q_n, p_1, p_2, \dots, p_n]\)

  • cov (array) – the covariance matrix of the Gaussian state

  • j (int) – the j th mode

  • hbar (float) – the hbar convention used in the commutation relation \([q, p]=i\hbar\)

Returns

the mean photon number in mode \(j\).

Return type

float

photon_number_mean_vector(mu, cov, hbar=2)[source]

Calculate the mean photon number of each of the modes in a Gaussian state

Parameters
  • mu (array) – vector of means of the Gaussian state using the ordering \([q_1, q_2, \dots, q_n, p_1, p_2, \dots, p_n]\)

  • cov (array) – the covariance matrix of the Gaussian state

  • hbar (float) – the hbar convention used in the commutation relation \([q, p]=i\hbar\)

Returns

the vector of means of the photon number distribution

Return type

array

prefactor(mu, cov, hbar=2)[source]

Returns the prefactor.

\[prefactor = \frac{e^{-\beta Q^{-1}\beta^*/2}}{n_1!\cdots n_m! \sqrt{|Q|}}\]
Parameters
  • mu (array) – length-\(2N\) vector of mean values \([\alpha,\alpha^*]\)

  • cov (array) – length-\(2N\) xp-covariance matrix

Returns

the prefactor

Return type

float

probabilities(mu, cov, cutoff, hbar=2.0, rtol=1e-05, atol=1e-08)[source]

Generate the Fock space probabilities of a Gaussian state up to a Fock space cutoff.

Parameters
  • mu (array) – vector of means of length 2*n_modes

  • cov (array) – covariance matrix of shape [2*n_modes, 2*n_modes]

  • cutoff (int) – cutoff in Fock space

  • hbar (float) – value of \(\hbar\) in the commutation relation :math;`[hat{x}, hat{p}]=ihbar`

  • rtol (float) – the relative tolerance parameter used in np.allclose

  • atol (float) – the absolute tolerance parameter used in np.allclose

Returns

Fock space probabilities up to cutoff. The shape of this tensor is [cutoff]*num_modes.

Return type

(array)

reduced_gaussian(mu, cov, modes)[source]

Returns the vector of means and the covariance matrix of the specified modes.

Parameters
  • mu (array) – a length-\(2N\) np.float64 vector of means.

  • cov (array) – a \(2N\times 2N\) np.float64 covariance matrix representing an \(N\) mode quantum state.

  • modes (int of Sequence[int]) – indices of the requested modes

Returns

where means is an array containing the vector of means, and cov is a square array containing the covariance matrix.

Return type

tuple (means, cov)

total_photon_num_dist_pure_state(cov, cutoff=50, hbar=2, padding_factor=2)[source]

Calculates the total photon number distribution of a pure state with zero mean.

Parameters
  • cov (array) – \(2N\times 2N\) covariance matrix in xp-ordering

  • cutoff (int) – Fock cutoff

  • tol (float) – tolerance for determining if displacement is negligible

  • hbar (float) – the value of \(\hbar\) in the commutation

  • padding_factor (int) – expanded size of the photon distribution to avoid accumulation of errors

Returns

Total photon number distribution

Return type

(array)

update_probabilities_with_loss(etas, probs)[source]

Given a list of transmissivities a tensor of probabilitites, calculate an updated tensor of probabilities after loss is applied.

Parameters
  • etas (list) – List of transmissitivities describing the loss in each of the modes

  • probs (array) – Array of probabilitites in the different modes

Returns

List of loss-updated probabilities with the same shape as probs.

Return type

array

update_probabilities_with_noise(probs_noise, probs)[source]

Given a list of noise probability distributions for each of the modes and a tensor of probabilitites, calculate an updated tensor of probabilities after noise is applied.

Parameters
  • probs_noise (list) – List of probability distributions describing the noise in each of the modes

  • probs (array) – Array of probabilitites in the different modes

Returns

List of noise-updated probabilities with the same shape as probs.

Return type

array