Note

This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.

scipy_gaussian_lstsq

scipy_gaussian_lstsq(outcome_data, shot_data, measurement_data, preparation_data, measurement_basis=None, preparation_basis=None, measurement_qubits=None, preparation_qubits=None, outcome_prior=0.5, max_weight=10000000000.0, **kwargs)[source]

Gaussian linear least-squares tomography fitter.

Note

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

Overview

This fitter uses the scipy_linear_lstsq() fitter to reconstructs the maximum-likelihood estimate of the Gaussian weighted least-squares log-likelihood function

\[\begin{split}\hat{rho} &= \mbox{argmin} -\log\mathcal{L}{\rho} \\ -\log\mathcal{L}(\rho) &= \sum_i \frac{1}{\sigma_i^2}(\mbox{Tr}[E_j\rho] - \hat{p}_i)^2 = \|W(Ax -y) \|_2^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 frequences \(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 indice data.

  • preparation_data (ndarray) – preparation basis indice data.

  • measurement_basis (Optional[MeasurementBasis]) – Optional, measurement matrix basis.

  • preparation_basis (Optional[PreparationBasis]) – Optional, preparation matrix basis.

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

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

  • outcome_prior (Union[ndarray, int]) – The Baysian 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 – additional kwargs for scipy.linalg.lstsq().

Raises:

AnalysisError – If the fitted vector is not a square matrix

Return type:

Dict

Returns:

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