qiskit-documentation/docs/api/qiskit/0.26/qiskit.algorithms.PhaseEsti...

132 lines
7.6 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: PhaseEstimationScale (v0.26)
description: API reference for qiskit.algorithms.PhaseEstimationScale in qiskit v0.26
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.algorithms.PhaseEstimationScale
---
<span id="qiskit-algorithms-phaseestimationscale" />
# qiskit.algorithms.PhaseEstimationScale
<Class id="qiskit.algorithms.PhaseEstimationScale" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.17/qiskit/algorithms/phase_estimators/phase_estimation_scale.py" signature="PhaseEstimationScale(bound)" modifiers="class">
Set and use a bound on eigenvalues of a Hermitian operator in order to ensure phases are in the desired range and to convert measured phases into eigenvectors.
The `bound` is set when constructing this class. Then the method `scale` is used to find the factor by which to scale the operator.
If `bound` is equal exactly to the largest eigenvalue, and the smallest eigenvalue is minus the largest, then these two eigenvalues will not be distinguished. For example, if the Hermitian operator is the Pauli Z operator with eigenvalues $1$ and $-1$, and `bound` is $1$, then both eigenvalues will be mapped to $1$. This can be avoided by making `bound` a bit larger.
Increasing `bound` decreases the part of the interval $[0, 1)$ that is used to map eigenvalues to `phi`. However, sometimes this results in a better determination of the eigenvalues, because 1) although there are fewer discrete phases in the useful range, it may shift one of the discrete phases closer to the actual phase. And, 2) If one of the discrete phases is close to, or exactly equal to the actual phase, then artifacts (probability) in neighboring phases will be reduced. This is important because the artifacts may be larger than the probability in a phase representing another eigenvalue of interest whose corresponding eigenstate has a relatively small weight in the input state.
**Parameters**
**bound** (`float`) an upper bound on the absolute value of the eigenvalues of a Hermitian operator. (The operator is not needed here.)
### \_\_init\_\_
<Function id="qiskit.algorithms.PhaseEstimationScale.__init__" signature="__init__(bound)">
**Parameters**
**bound** (`float`) an upper bound on the absolute value of the eigenvalues of a Hermitian operator. (The operator is not needed here.)
</Function>
## Methods
| | |
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| [`__init__`](#qiskit.algorithms.PhaseEstimationScale.__init__ "qiskit.algorithms.PhaseEstimationScale.__init__")(bound) | **type bound**`float` |
| [`from_pauli_sum`](#qiskit.algorithms.PhaseEstimationScale.from_pauli_sum "qiskit.algorithms.PhaseEstimationScale.from_pauli_sum")(pauli\_sum) | Create a PhaseEstimationScale from a SummedOp representing a sum of Pauli Operators. |
| [`scale_phase`](#qiskit.algorithms.PhaseEstimationScale.scale_phase "qiskit.algorithms.PhaseEstimationScale.scale_phase")(phi\[, id\_coefficient]) | Convert a phase into an eigenvalue. |
| [`scale_phases`](#qiskit.algorithms.PhaseEstimationScale.scale_phases "qiskit.algorithms.PhaseEstimationScale.scale_phases")(phases\[, id\_coefficient]) | Convert a list or dict of phases to eigenvalues. |
## Attributes
| | |
| ------------------------------------------------------------------------------------------------------- | -------------------------------------- |
| [`scale`](#qiskit.algorithms.PhaseEstimationScale.scale "qiskit.algorithms.PhaseEstimationScale.scale") | Return the Hamiltonian scaling factor. |
### from\_pauli\_sum
<Function id="qiskit.algorithms.PhaseEstimationScale.from_pauli_sum" signature="from_pauli_sum(pauli_sum)" modifiers="classmethod">
Create a PhaseEstimationScale from a SummedOp representing a sum of Pauli Operators.
It is assumed that the `pauli_sum` is the sum of `PauliOp` objects. The bound on the absolute value of the eigenvalues of the sum is obtained as the sum of the absolute values of the coefficients of the terms. This is the best bound available in the generic case. A `PhaseEstimationScale` object is instantiated using this bound.
**Parameters**
**pauli\_sum** (`SummedOp`) A `SummedOp` whose terms are `PauliOp` objects.
**Raises**
**ValueError** if `pauli_sum` is not a sum of Pauli operators.
**Return type**
`PhaseEstimationScale`
**Returns**
A `PhaseEstimationScale` object
</Function>
### scale
<Attribute id="qiskit.algorithms.PhaseEstimationScale.scale">
Return the Hamiltonian scaling factor.
Return the scale factor by which a Hermitian operator must be multiplied so that the phase of the corresponding unitary is restricted to $[-\pi, \pi]$. This factor is computed from the bound on the absolute values of the eigenvalues of the operator. The methods `scale_phase` and `scale_phases` are used recover the eigenvalues corresponding the original (unscaled) Hermitian operator.
**Return type**
`float`
**Returns**
The scale factor.
</Attribute>
### scale\_phase
<Function id="qiskit.algorithms.PhaseEstimationScale.scale_phase" signature="scale_phase(phi, id_coefficient=0.0)">
Convert a phase into an eigenvalue.
The input phase `phi` corresponds to the eigenvalue of a unitary obtained by exponentiating a scaled Hermitian operator. Recall that the phase is obtained from `phi` as $2\pi\phi$. Furthermore, the Hermitian operator was scaled so that `phi` is restricted to $[-1/2, 1/2]$, corresponding to phases in $[-\pi, \pi]$. But the values of phi read from the phase-readout register are in $[0, 1)$. Any value of `phi` greater than $1/2$ corresponds to a raw phase of minus the complement with respect to 1. After this possible shift, the phase is scaled by the inverse of the factor by which the Hermitian operator was scaled to recover the eigenvalue of the Hermitian operator.
**Parameters**
* **phi** (`float`) Normalized phase in $[0, 1)$ to be converted to an eigenvalue.
* **id\_coefficient** (`float`) All eigenvalues are shifted by this value.
**Return type**
`float`
**Returns**
An eigenvalue computed from the input phase.
</Function>
### scale\_phases
<Function id="qiskit.algorithms.PhaseEstimationScale.scale_phases" signature="scale_phases(phases, id_coefficient=0.0)">
Convert a list or dict of phases to eigenvalues.
The values in the list, or keys in the dict, are values of ```phi` and are converted as described in the description of ``scale_phase```. In case `phases` is a dict, the values of the dict are passed unchanged.
**Parameters**
* **phases** (`Union`\[`List`, `Dict`]) a list or dict of values of `phi`.
* **id\_coefficient** (`float`) All eigenvalues are shifted by this value.
**Return type**
`Union`\[`Dict`, `List`]
**Returns**
Eigenvalues computed from phases.
</Function>
</Class>