uniqc.algorithms.core.circuits.amplitude_estimation module

Quantum Amplitude Estimation (QAE) circuit.

uniqc.algorithms.core.circuits.amplitude_estimation.amplitude_estimation_circuit(oracle=None, *, qubits=None, eval_qubits=None, state_prep=None)[source]

Build a Quantum Amplitude Estimation (QAE) circuit fragment.

c = amplitude_estimation_circuit(
    oracle, qubits=[3, 4], eval_qubits=[0, 1, 2]
)  # -> Circuit

The optional state_prep Circuit replaces the default H^{⊗n} state preparation on the search register.

uniqc.algorithms.core.circuits.amplitude_estimation.amplitude_estimation_example()[source]

Return a small QAE circuit for tests/docs.

uniqc.algorithms.core.circuits.amplitude_estimation.amplitude_estimation_result(counts, n_eval_qubits)[source]

Estimate probability a from QAE measurement results.

Converts the most-frequent measurement outcome to an angle θ and computes a = sin²(θ).

The QAE phase relation is theta = pi * m / 2^(M+1) where m is the integer outcome and M = n_eval_qubits. The extra factor of two compared to the bare QPE formula comes from the fact that the Grover operator’s eigenphase is 2 theta rather than theta.

Parameters:
  • counts – Dictionary mapping measurement outcomes (bit-strings or integers) to frequencies/counts.

  • n_eval_qubits – Number of evaluation qubits used in QAE.

Returns:

Estimated probability a ∈ [0, 1].

uniqc.algorithms.core.circuits.amplitude_estimation.grover_operator(oracle=None, *, qubits=None, state_prep=None)[source]

Build one Grover iteration fragment G = A · S₀ · A† · S_f.

g = grover_operator(oracle, qubits=[0, 1, 2])  # -> Circuit