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.
cvxpy_linear_lstsq¶
- cvxpy_linear_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, conditional_preparation_indices=None, trace='auto', psd=True, trace_preserving='auto', partial_trace=None, weights=None, **kwargs)[source]¶
Constrained weighted linear least-squares tomography fitter.
- Overview
This fitter reconstructs the maximum-likelihood estimate by using
cvxpy
to minimize the constrained least-squares negative log likelihood functionsubject to
Positive-semidefinite (
psd=True
): is constrained to be a positive-semidefinite matrix.Trace (
trace=t
): is constrained to have the specified trace.Trace preserving (
trace_preserving=True
): When performing process tomography the Choi-state represents is constrained to be trace preserving.
where
is the matrix of measurement operators is the vector of expectation value data for each projector corresponding to estimates of . is the vectorized density matrix (or Choi-matrix) to be fitted .
Note
Linear least-squares constructs the full basis matrix
as a dense numpy array so should not be used for than 5 or 6 qubits. For larger number of qubits try thelinear_inversion()
fitter function.- 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.conditional_measurement_indices (
Optional
[Tuple
[int
,...
]]) – 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 (
Optional
[Tuple
[int
,...
]]) – Optional, conditional preparation data indices. If set this will return a list of fitted states conditioned on a fixed basis preparation of these qubits.trace (
Union
[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 (
Union
[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 (
Optional
[ndarray
]) – Enforce conditional fitted Choi matrices to partial trace to POVM matrices.weights (
Optional
[ndarray
]) – Optional array of weights for least squares objective. Weights should be the same shape as the outcome_data.kwargs – kwargs for cvxpy solver.
- Raises:
QiskitError – If CVXPy is not installed on the current system.
AnalysisError – If analysis fails.
- Return type:
Tuple
[ndarray
,Dict
]- Returns:
The fitted matrix rho that maximizes the least-squares likelihood function.