cvxpy_gaussian_lstsq#

cvxpy_gaussian_lstsq(outcome_data, shot_data, measurement_data, preparation_data, measurement_basis=None, preparation_basis=None, measurement_qubits=None, preparation_qubits=None, conditional_measurement_indices=None, trace='auto', psd=True, trace_preserving='auto', partial_trace=None, outcome_prior=0.5, max_weight=10000000000.0, **kwargs)[source]#

Constrained Gaussian linear least-squares tomography fitter.

Note

This function calls cvxpy_linear_lstsq() with a Gaussian weights vector. Refer to its documentation for additional details.

Overview

This fitter reconstructs the maximum-likelihood estimate by using cvxpy to minimize the constrained least-squares negative log likelihood function

\[\begin{split}\hat{\rho} &= \mbox{argmin} (-\log\mathcal{L}{\rho}) \\ &= \mbox{argmin }\|W(Ax - y) \|_2^2 \\ -\log\mathcal{L}(\rho) &= |W(Ax -y) \|_2^2 \\ &= \sum_i \frac{1}{\sigma_i^2}(\mbox{Tr}[E_j\rho] - \hat{p}_i)^2\end{split}\]
Additional Details

The Gaussian weights are estimated from the observed frequency and shot data via a Bayesian update of a Dirichlet distribution with observed outcome data frequencies \(f_i(s)\), and Dirichlet prior \(\alpha_i(s)\) for tomography basis index i and measurement outcome s.

The mean posterior probabilities are computed as

where \(N_i = \sum_s f_i(s)\) is the total number of shots, and \(\bar{\alpha}_i = \sum_s \alpha_i(s)\) is the norm of the prior.

Parameters:
  • outcome_data (ndarray) – measurement outcome frequency data.

  • shot_data (ndarray) – basis measurement total shot data.

  • measurement_data (ndarray) – measurement basis index data.

  • preparation_data (ndarray) – preparation basis index data.

  • measurement_basis (MeasurementBasis | None) – Optional, measurement matrix basis.

  • preparation_basis (PreparationBasis | None) – Optional, preparation matrix basis.

  • measurement_qubits (Tuple[int, ...] | None) – Optional, the physical qubits that were measured. If None they are assumed to be [0, ..., M-1] for M measured qubits.

  • preparation_qubits (Tuple[int, ...] | None) – Optional, the physical qubits that were prepared. If None they are assumed to be [0, ..., N-1] for N prepared qubits.

  • conditional_measurement_indices (Tuple[int, ...] | None) – Optional, conditional measurement data indices. If set this will return a list of conditional fitted states conditioned on a fixed basis measurement of these qubits.

  • trace (None | float | str) – trace constraint for the fitted matrix. If “auto” this will be set to 1 for QST or the input dimension for QST (default: “auto”).

  • psd (bool) – If True rescale the eigenvalues of fitted matrix to be positive semidefinite (default: True)

  • trace_preserving (None | bool | str) – Enforce the fitted matrix to be trace preserving when fitting a Choi-matrix in quantum process tomography. If “auto” this will be set to True for QPT and False for QST (default: “auto”).

  • partial_trace (ndarray | None) – Enforce conditional fitted Choi matrices to partial trace to POVM matrices.

  • outcome_prior (ndarray | int) – The Bayesian prior \(\alpha\) to use computing Gaussian weights. See additional information.

  • max_weight (float) – Set the maximum value allowed for weights vector computed from tomography data variance.

  • kwargs – kwargs for cvxpy solver.

Raises:
  • QiskitError – If CVXPY is not installed on the current system.

  • AnalysisError – If analysis fails.

Returns:

The fitted matrix rho that maximizes the least-squares likelihood function.

Return type:

Dict