linear_inversion

linear_inversion(outcome_data, shot_data, measurement_data, preparation_data, measurement_basis=None, preparation_basis=None, measurement_qubits=None, preparation_qubits=None, conditional_measurement_indices=None, conditional_preparation_indices=None, atol=1e-08)[source]

Linear inversion tomography fitter.

Overview

This fitter uses linear inversion to reconstructs the maximum-likelihood estimate of the least-squares log-likelihood function

ρ^=argmin logLρ=argmin i(Tr[Ejρ]p^i)2=argmin Axy22

where

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

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

  • x=|ρ is the vectorized density matrix.

Additional Details

The linear inversion solution is given by

ρ^=ip^iDi

where measurement probabilities p^i=fi/ni are estimated from the observed count frequencies fi in ni shots for each basis element i, and Di is the dual basis element constructed from basis {Ei} via:

Note

The Linear inversion fitter treats the input measurement and preparation bases as local bases and constructs separate 1-qubit dual basis for each individual qubit.

Linear inversion is only possible if the input bases are local and a spanning set for the vector space of the reconstructed matrix (tomographically complete). If the basis is not tomographically complete the scipy_linear_lstsq() or cvxpy_linear_lstsq() function can be used to solve the same objective function via least-squares optimization.

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

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

  • measurement_data (ndarray) – measurement basis index data.

  • preparation_data (ndarray) – preparation basis index data.

  • measurement_basis (MeasurementBasis | None) – the tomography measurement basis.

  • preparation_basis (PreparationBasis | None) – the tomography preparation 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] forN prepared qubits.

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

  • conditional_preparation_indices (ndarray | None) – Optional, conditional preparation data indices. If set this will return a list of fitted states conditioned on a fixed basis preparation of these qubits.

  • atol (float) – truncate any probabilities below this value to zero.

Raises:

AnalysisError – If the fitted vector is not a square matrix

Returns:

The fitted matrix rho.

Return type:

Tuple[ndarray, Dict]