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_linear_lstsq

scipy_linear_lstsq(outcome_data, shot_data, measurement_data, preparation_data, measurement_basis=None, preparation_basis=None, measurement_qubits=None, preparation_qubits=None, weights=None, **kwargs)[source]

Weighted linear least-squares tomography fitter.

Overview

This fitter reconstructs the maximum-likelihood estimate by using scipy.linalg.lstsq() to minimize the least-squares negative log likelihood function

ρ^=argmin logLρ=argmin iwi2(Tr[Ejρ]p^i)2=argmin W(Axy)22

where

  • A=j|jEj| is the matrix of measured basis elements.

  • W=jwj|jj| is an optional diagonal weights matrix if an optional weights vector is supplied.

  • y=jp^j|j is the vector of estimated measurement outcome probabilites for each basis element.

  • x=|ρ is the vectorized density matrix.

Note

Linear least-squares constructs the full basis matrix A as a dense numpy array so should not be used for than 5 or 6 qubits. For larger number of qubits try the linear_inversion() fitter function.

Deprecated since version unknown: The scipy lstsq tomography fitters are deprecated as of 0.4 and will be removed after the 0.5 release. Use the linear_lstsq, cvxpy_linear_lstsq, or cvxpy_gaussian_lstsq fitters instead.

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.

  • weights (Optional[ndarray]) – Optional array of weights for least squares objective.

  • kwargs – additional kwargs for scipy.linalg.lstsq().

Raises:

AnalysisError – If the fitted vector is not a square matrix

Return type:

Tuple[ndarray, Dict]

Returns:

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