guppyalgos.algorithms.amplitude_amplification.qae¶
Functions for QAE.
Functions
|
Estimate the amplitude by repeated prepare-and-measure sampling. |
|
Prepare \(A\ket{0}\) and measure the target qubit once. |
- guppyalgos.algorithms.amplitude_amplification.qae.prepare_and_measure(state_prep, repeat)¶
Estimate the amplitude by repeated prepare-and-measure sampling.
Runs
prepare_and_measure_once()repeattimes and returns the fraction of repetitions in which the target was measured in \(\ket{1}\), i.e.count(1) / repeat. The estimate converges to the amplitude \(a = P(\text{target} = 1)\) with standard error \(\sqrt{a(1-a)/repeat}\).- Parameters:
state_prep – The state-preparation unitary \(A\); see
prepare_and_measure_once().repeat – The number of prepare-and-measure repetitions. Must be at least
1.
- Returns:
The estimated amplitude in
[0, 1].
- guppyalgos.algorithms.amplitude_amplification.qae.prepare_and_measure_once(state_prep)¶
Prepare \(A\ket{0}\) and measure the target qubit once.
Allocates an
n-qubit register together with a single target qubit, all in \(\ket{0}\), applies the state-preparation unitarystate_prep(\(A\)), and measures the target in the computational basis. The register is discarded.- Parameters:
state_prep – The state-preparation unitary \(A\), acting on the register (assumed to start in \(\ket{0}\)) and the target qubit. It must flag the “good” subspace on the target qubit, i.e. arrange that measuring the target yields \(\ket{1}\) with probability equal to the amplitude.
- Returns:
The measured target outcome,
Truefor \(\ket{1}\) andFalsefor \(\ket{0}\).