174 lines
6.5 KiB
Plaintext
174 lines
6.5 KiB
Plaintext
---
|
||
title: AmplitudeEstimation
|
||
description: API reference for qiskit.algorithms.AmplitudeEstimation
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.algorithms.AmplitudeEstimation
|
||
---
|
||
|
||
# AmplitudeEstimation
|
||
|
||
<Class id="qiskit.algorithms.AmplitudeEstimation" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.19/qiskit/algorithms/amplitude_estimators/ae.py" signature="AmplitudeEstimation(num_eval_qubits, phase_estimation_circuit=None, iqft=None, quantum_instance=None)" modifiers="class">
|
||
Bases: `qiskit.algorithms.amplitude_estimators.amplitude_estimator.AmplitudeEstimator`
|
||
|
||
The Quantum Phase Estimation-based Amplitude Estimation algorithm.
|
||
|
||
This class implements the original Quantum Amplitude Estimation (QAE) algorithm, introduced by \[1]. This canonical version uses quantum phase estimation along with a set of $m$ additional evaluation qubits to find an estimate $\tilde{a}$, that is restricted to the grid
|
||
|
||
$$
|
||
\tilde{a} \in \{\sin^2(\pi y / 2^m) : y = 0, ..., 2^{m-1}\}
|
||
$$
|
||
|
||
More evaluation qubits produce a finer sampling grid, therefore the accuracy of the algorithm increases with $m$.
|
||
|
||
Using a maximum likelihood post processing, this grid constraint can be circumvented. This improved estimator is implemented as well, see \[2] Appendix A for more detail.
|
||
|
||
**References**
|
||
|
||
**\[1]: Brassard, G., Hoyer, P., Mosca, M., & Tapp, A. (2000).**
|
||
|
||
Quantum Amplitude Amplification and Estimation. [arXiv:quant-ph/0005055](http://arxiv.org/abs/quant-ph/0005055).
|
||
|
||
**\[2]: Grinko, D., Gacon, J., Zoufal, C., & Woerner, S. (2019).**
|
||
|
||
Iterative Quantum Amplitude Estimation. [arXiv:1912.05559](https://arxiv.org/abs/1912.05559).
|
||
|
||
**Parameters**
|
||
|
||
* **num\_eval\_qubits** (`int`) – The number of evaluation qubits.
|
||
* **phase\_estimation\_circuit** (`Optional`\[`QuantumCircuit`]) – The phase estimation circuit used to run the algorithm. Defaults to the standard phase estimation circuit from the circuit library, qiskit.circuit.library.PhaseEstimation when None.
|
||
* **iqft** (`Optional`\[`QuantumCircuit`]) – The inverse quantum Fourier transform component, defaults to using a standard implementation from qiskit.circuit.library.QFT when None.
|
||
* **quantum\_instance** (`Union`\[`Backend`, `BaseBackend`, `QuantumInstance`, `None`]) – The backend (or QuantumInstance) to execute the circuits on.
|
||
|
||
**Raises**
|
||
|
||
**ValueError** – If the number of evaluation qubits is smaller than 1.
|
||
|
||
## Methods
|
||
|
||
### compute\_confidence\_interval
|
||
|
||
<Function id="qiskit.algorithms.AmplitudeEstimation.compute_confidence_interval" signature="AmplitudeEstimation.compute_confidence_interval(result, alpha=0.05, kind='likelihood_ratio')" modifiers="static">
|
||
Compute the (1 - alpha) confidence interval.
|
||
|
||
**Parameters**
|
||
|
||
* **result** (`AmplitudeEstimationResult`) – An amplitude estimation result for which to compute the confidence interval.
|
||
* **alpha** (`float`) – Confidence level: compute the (1 - alpha) confidence interval.
|
||
* **kind** (`str`) – The method to compute the confidence interval, can be ‘fisher’, ‘observed\_fisher’ or ‘likelihood\_ratio’ (default)
|
||
|
||
**Return type**
|
||
|
||
`Tuple`\[`float`, `float`]
|
||
|
||
**Returns**
|
||
|
||
The (1 - alpha) confidence interval of the specified kind.
|
||
|
||
**Raises**
|
||
|
||
* **AquaError** – If ‘mle’ is not in self.\_ret.keys() (i.e. run was not called yet).
|
||
* **NotImplementedError** – If the confidence interval method kind is not implemented.
|
||
</Function>
|
||
|
||
### compute\_mle
|
||
|
||
<Function id="qiskit.algorithms.AmplitudeEstimation.compute_mle" signature="AmplitudeEstimation.compute_mle(result, apply_post_processing=False)" modifiers="static">
|
||
Compute the Maximum Likelihood Estimator (MLE).
|
||
|
||
**Parameters**
|
||
|
||
* **result** (`AmplitudeEstimationResult`) – An amplitude estimation result object.
|
||
* **apply\_post\_processing** (`bool`) – If True, apply the post processing to the MLE before returning it.
|
||
|
||
**Return type**
|
||
|
||
`float`
|
||
|
||
**Returns**
|
||
|
||
The MLE for the provided result object.
|
||
</Function>
|
||
|
||
### construct\_circuit
|
||
|
||
<Function id="qiskit.algorithms.AmplitudeEstimation.construct_circuit" signature="AmplitudeEstimation.construct_circuit(estimation_problem, measurement=False)">
|
||
Construct the Amplitude Estimation quantum circuit.
|
||
|
||
**Parameters**
|
||
|
||
* **estimation\_problem** (`EstimationProblem`) – The estimation problem for which to construct the QAE circuit.
|
||
* **measurement** (`bool`) – Boolean flag to indicate if measurements should be included in the circuit.
|
||
|
||
**Return type**
|
||
|
||
`QuantumCircuit`
|
||
|
||
**Returns**
|
||
|
||
The QuantumCircuit object for the constructed circuit.
|
||
</Function>
|
||
|
||
### estimate
|
||
|
||
<Function id="qiskit.algorithms.AmplitudeEstimation.estimate" signature="AmplitudeEstimation.estimate(estimation_problem)">
|
||
Run the amplitude estimation algorithm on provided estimation problem.
|
||
|
||
**Parameters**
|
||
|
||
**estimation\_problem** (`EstimationProblem`) – The estimation problem.
|
||
|
||
**Return type**
|
||
|
||
`AmplitudeEstimationResult`
|
||
|
||
**Returns**
|
||
|
||
An amplitude estimation results object.
|
||
|
||
**Raises**
|
||
|
||
**ValueError** – If state\_preparation or objective\_qubits are not set in the estimation\_problem.
|
||
</Function>
|
||
|
||
### evaluate\_measurements
|
||
|
||
<Function id="qiskit.algorithms.AmplitudeEstimation.evaluate_measurements" signature="AmplitudeEstimation.evaluate_measurements(circuit_results, threshold=1e-06)">
|
||
Evaluate the results from the circuit simulation.
|
||
|
||
Given the probabilities from statevector simulation of the QAE circuit, compute the probabilities that the measurements y/gridpoints a are the best estimate.
|
||
|
||
**Parameters**
|
||
|
||
* **circuit\_results** (`Union`\[`Dict`\[`str`, `int`], `ndarray`]) – The circuit result from the QAE circuit. Can be either a counts dict or a statevector.
|
||
* **threshold** (`float`) – Measurements with probabilities below the threshold are discarded.
|
||
|
||
**Return type**
|
||
|
||
`Tuple`\[`Dict`\[`int`, `float`], `Dict`\[`float`, `float`]]
|
||
|
||
**Returns**
|
||
|
||
**Dictionaries containing the a gridpoints with respective probabilities and**
|
||
|
||
y measurements with respective probabilities, in this order.
|
||
</Function>
|
||
|
||
## Attributes
|
||
|
||
### quantum\_instance
|
||
|
||
<Attribute id="qiskit.algorithms.AmplitudeEstimation.quantum_instance">
|
||
Get the quantum instance.
|
||
|
||
**Return type**
|
||
|
||
`Optional`\[`QuantumInstance`]
|
||
|
||
**Returns**
|
||
|
||
The quantum instance used to run this algorithm.
|
||
</Attribute>
|
||
</Class>
|
||
|