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.
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
\[\begin{split}\hat{\rho} &= -\mbox{argmin }\log\mathcal{L}{\rho} \\ &= \mbox{argmin }\sum_i (\mbox{Tr}[E_j\rho] - \hat{p}_i)^2 \\ &= \mbox{argmin }\|Ax - y \|_2^2\end{split}\]where
\(A = \sum_j |j \rangle\!\langle\!\langle E_j|\) is the matrix of measured basis elements.
\(y = \sum_j \hat{p}_j |j\rangle\) is the vector of estimated measurement outcome probabilities for each basis element.
\(x = |\rho\rangle\!\rangle\) is the vectorized density matrix.
- Additional Details
The linear inversion solution is given by
\[\hat{\rho} = \sum_i \hat{p}_i D_i\]where measurement probabilities \(\hat{p}_i = f_i / n_i\) are estimated from the observed count frequencies \(f_i\) in \(n_i\) shots for each basis element \(i\), and \(D_i\) is the dual basis element constructed from basis \(\{E_i\}\) 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()
orcvxpy_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]