161 lines
10 KiB
Plaintext
161 lines
10 KiB
Plaintext
---
|
||
title: LocalReadoutMitigator (v1.2)
|
||
description: API reference for qiskit.result.LocalReadoutMitigator in qiskit v1.2
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.result.LocalReadoutMitigator
|
||
---
|
||
|
||
# LocalReadoutMitigator
|
||
|
||
<Class id="qiskit.result.LocalReadoutMitigator" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/result/mitigation/local_readout_mitigator.py#L28-L320" signature="qiskit.result.LocalReadoutMitigator(assignment_matrices=None, qubits=None, backend=None)" modifiers="class">
|
||
Bases: [`BaseReadoutMitigator`](qiskit.result.BaseReadoutMitigator "qiskit.result.mitigation.base_readout_mitigator.BaseReadoutMitigator")
|
||
|
||
1-qubit tensor product readout error mitigator.
|
||
|
||
Mitigates [`expectation_value()`](#qiskit.result.LocalReadoutMitigator.expectation_value "qiskit.result.LocalReadoutMitigator.expectation_value") and [`quasi_probabilities()`](#qiskit.result.LocalReadoutMitigator.quasi_probabilities "qiskit.result.LocalReadoutMitigator.quasi_probabilities"). The mitigator should either be calibrated using qiskit experiments, or calculated directly from the backend properties. This mitigation method should be used in case the readout errors of the qubits are assumed to be uncorrelated. For *N* qubits there are *N* mitigation matrices, each of size $2 x 2$ and the mitigation complexity is $O(2^N)$, so it is more efficient than the [`CorrelatedReadoutMitigator`](qiskit.result.CorrelatedReadoutMitigator "qiskit.result.CorrelatedReadoutMitigator") class.
|
||
|
||
Initialize a LocalReadoutMitigator
|
||
|
||
**Parameters**
|
||
|
||
* **assignment\_matrices** ([*List*](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.13)")*\[*[*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.1)")*] | None*) – Optional, list of single-qubit readout error assignment matrices.
|
||
* **qubits** ([*Iterable*](https://docs.python.org/3/library/typing.html#typing.Iterable "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*] | None*) – Optional, the measured physical qubits for mitigation.
|
||
* **backend** – Optional, backend name.
|
||
|
||
**Raises**
|
||
|
||
[**QiskitError**](exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") – matrices sizes do not agree with number of qubits
|
||
|
||
## Attributes
|
||
|
||
### qubits
|
||
|
||
<Attribute id="qiskit.result.LocalReadoutMitigator.qubits">
|
||
The device qubits for this mitigator
|
||
</Attribute>
|
||
|
||
### settings
|
||
|
||
<Attribute id="qiskit.result.LocalReadoutMitigator.settings">
|
||
Return settings.
|
||
</Attribute>
|
||
|
||
## Methods
|
||
|
||
### assignment\_matrix
|
||
|
||
<Function id="qiskit.result.LocalReadoutMitigator.assignment_matrix" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/result/mitigation/local_readout_mitigator.py#L249-L270" signature="assignment_matrix(qubits=None)">
|
||
Return the measurement assignment matrix for specified qubits.
|
||
|
||
The assignment matrix is the stochastic matrix $A$ which assigns a noisy measurement probability distribution to an ideal input measurement distribution: $P(i|j) = \langle i | A | j \rangle$.
|
||
|
||
**Parameters**
|
||
|
||
**qubits** ([*List*](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*] | None*) – Optional, qubits being measured for operator expval.
|
||
|
||
**Returns**
|
||
|
||
the assignment matrix A.
|
||
|
||
**Return type**
|
||
|
||
np.ndarray
|
||
</Function>
|
||
|
||
### expectation\_value
|
||
|
||
<Function id="qiskit.result.LocalReadoutMitigator.expectation_value" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/result/mitigation/local_readout_mitigator.py#L100-L166" signature="expectation_value(data, diagonal=None, qubits=None, clbits=None, shots=None)">
|
||
Compute the mitigated expectation value of a diagonal observable.
|
||
|
||
This computes the mitigated estimator of $\langle O \rangle = \mbox{Tr}[\rho. O]$ of a diagonal observable $O = \sum_{x\in\{0, 1\}^n} O(x)|x\rangle\!\langle x|$.
|
||
|
||
**Parameters**
|
||
|
||
* **data** ([*Counts*](qiskit.result.Counts "qiskit.result.counts.Counts")) – Counts object
|
||
* **diagonal** ([*Callable*](https://docs.python.org/3/library/typing.html#typing.Callable "(in Python v3.13)") *|*[*dict*](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.13)") *|*[*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *|*[*ndarray*](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.1)") *| None*) – Optional, the vector of diagonal values for summing the expectation value. If `None` the default value is $[1, -1]^\otimes n$.
|
||
* **qubits** ([*Iterable*](https://docs.python.org/3/library/typing.html#typing.Iterable "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*] | None*) – Optional, the measured physical qubits the count bitstrings correspond to. If None qubits are assumed to be $[0, ..., n-1]$.
|
||
* **clbits** ([*List*](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*] | None*) – Optional, if not None marginalize counts to the specified bits.
|
||
* **shots** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| None*) – the number of shots.
|
||
|
||
**Returns**
|
||
|
||
the expectation value and an upper bound of the standard deviation.
|
||
|
||
**Return type**
|
||
|
||
([float](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)"), [float](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)"))
|
||
|
||
**Additional Information:**
|
||
|
||
The diagonal observable $O$ is input using the `diagonal` kwarg as a list or Numpy array $[O(0), ..., O(2^n -1)]$. If no diagonal is specified the diagonal of the Pauli operator :math\`O = mbox\{diag}(Z^\{otimes n}) = \[1, -1]^\{otimes n}\` is used. The `clbits` kwarg is used to marginalize the input counts dictionary over the specified bit-values, and the `qubits` kwarg is used to specify which physical qubits these bit-values correspond to as `circuit.measure(qubits, clbits)`.
|
||
</Function>
|
||
|
||
### mitigation\_matrix
|
||
|
||
<Function id="qiskit.result.LocalReadoutMitigator.mitigation_matrix" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/result/mitigation/local_readout_mitigator.py#L225-L247" signature="mitigation_matrix(qubits=None)">
|
||
Return the measurement mitigation matrix for the specified qubits.
|
||
|
||
The mitigation matrix $A^{-1}$ is defined as the inverse of the [`assignment_matrix()`](#qiskit.result.LocalReadoutMitigator.assignment_matrix "qiskit.result.LocalReadoutMitigator.assignment_matrix") $A$.
|
||
|
||
**Parameters**
|
||
|
||
**qubits** ([*List*](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*] |* [*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| None*) – Optional, qubits being measured for operator expval. if a single int is given, it is assumed to be the index of the qubit in self.\_qubits
|
||
|
||
**Returns**
|
||
|
||
the measurement error mitigation matrix $A^{-1}$.
|
||
|
||
**Return type**
|
||
|
||
np.ndarray
|
||
</Function>
|
||
|
||
### quasi\_probabilities
|
||
|
||
<Function id="qiskit.result.LocalReadoutMitigator.quasi_probabilities" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/result/mitigation/local_readout_mitigator.py#L168-L223" signature="quasi_probabilities(data, qubits=None, clbits=None, shots=None)">
|
||
Compute mitigated quasi probabilities value.
|
||
|
||
**Parameters**
|
||
|
||
* **data** ([*Counts*](qiskit.result.Counts "qiskit.result.counts.Counts")) – counts object
|
||
* **qubits** ([*List*](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*] | None*) – qubits the count bitstrings correspond to.
|
||
* **clbits** ([*List*](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*] | None*) – Optional, marginalize counts to just these bits.
|
||
* **shots** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)") *| None*) – Optional, the total number of shots, if None shots will be calculated as the sum of all counts.
|
||
|
||
**Returns**
|
||
|
||
**A dictionary containing pairs of \[output, mean] where “output”**
|
||
|
||
is the key in the dictionaries, which is the length-N bitstring of a measured standard basis state, and “mean” is the mean of non-zero quasi-probability estimates.
|
||
|
||
**Return type**
|
||
|
||
[QuasiDistribution](qiskit.result.QuasiDistribution "qiskit.result.QuasiDistribution")
|
||
|
||
**Raises**
|
||
|
||
[**QiskitError**](exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") – if qubit and clbit kwargs are not valid.
|
||
</Function>
|
||
|
||
### stddev\_upper\_bound
|
||
|
||
<Function id="qiskit.result.LocalReadoutMitigator.stddev_upper_bound" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/result/mitigation/local_readout_mitigator.py#L281-L292" signature="stddev_upper_bound(shots, qubits=None)">
|
||
Return an upper bound on standard deviation of expval estimator.
|
||
|
||
**Parameters**
|
||
|
||
* **shots** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) – Number of shots used for expectation value measurement.
|
||
* **qubits** ([*List*](https://docs.python.org/3/library/typing.html#typing.List "(in Python v3.13)")*\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*] | None*) – qubits being measured for operator expval.
|
||
|
||
**Returns**
|
||
|
||
the standard deviation upper bound.
|
||
|
||
**Return type**
|
||
|
||
[float](https://docs.python.org/3/library/functions.html#float "(in Python v3.13)")
|
||
</Function>
|
||
</Class>
|
||
|