MaximumLikelihoodAmplitudeEstimation
class MaximumLikelihoodAmplitudeEstimation(num_oracle_circuits, a_factory=None, q_factory=None, i_objective=None, likelihood_evals=None, quantum_instance=None)
The Maximum Likelihood Amplitude Estimation algorithm.
This class implements the an quantum amplitude estimation (QAE) algorithm without phase estimation, according to https://arxiv.org/abs/1904.10246. In comparison to the original QAE algorithm (https://arxiv.org/abs/quant-ph/0005055), this implementation relies solely on different powers of the Grover algorithm and does not require ancilla qubits. Finally, the estimate is determined via a maximum likelihood estimation, which is why this class in named MaximumLikelihoodAmplitudeEstimation.
Parameters
- num_oracle_circuits (
int
) – The number of circuits applying different powers of the Grover oracle Q. The (num_oracle_circuits + 1) executed circuits will be [id, Q^2^0, …, Q^2^{num_oracle_circuits-1}] A |0>, where A is the problem unitary encoded in the argument a_factory. Has a minimum value of 1. - a_factory (
Optional
[CircuitFactory
]) – The CircuitFactory subclass object representing the problem unitary. - q_factory (
Optional
[CircuitFactory
]) – The CircuitFactory subclass object representing. an amplitude estimation sample (based on a_factory) - i_objective (
Optional
[int
]) – The index of the objective qubit, i.e. the qubit marking ‘good’ solutions with the state |1> and ‘bad’ solutions with the state |0> - likelihood_evals (
Optional
[int
]) – The number of gridpoints for the maximum search of the likelihood function - quantum_instance (
Union
[QuantumInstance
,BaseBackend
,None
]) – Quantum Instance or Backend
Attributes
a_factory
Get the A operator encoding the amplitude a that’s approximated, i.e.
A |0>_n |0> = sqrt{1 - a} |psi_0>_n |0> + sqrt{a} |psi_1>_n |1>
see the original Brassard paper (https://arxiv.org/abs/quant-ph/0005055) for more detail.
Returns
the A operator as CircuitFactory
Return type
backend
i_objective
Get the index of the objective qubit. The objective qubit marks the |psi_0> state (called ‘bad states’ in https://arxiv.org/abs/quant-ph/0005055) with |0> and |psi_1> (‘good’ states) with |1>. If the A operator performs the mapping
A |0>_n |0> = sqrt{1 - a} |psi_0>_n |0> + sqrt{a} |psi_1>_n |1>
then, the objective qubit is the last one (which is either |0> or |1>).
If the objective qubit (i_objective) is not set, we check if the Q operator (q_factory) is set and return the index specified there. If the q_factory is not defined, the index equals the number of qubits of the A operator (a_factory) minus one. If also the a_factory is not set, return None.
Returns
the index of the objective qubit
Return type
int
q_factory
Get the Q operator, or Grover-operator for the Amplitude Estimation algorithm, i.e.
Q = -A S_0 A^{-1} S_psi0,
where S_0 reflects about the |0>_n state and S_psi0 reflects about |psi_0>_n. See https://arxiv.org/abs/quant-ph/0005055 for more detail.
If the Q operator is not set, we try to build it from the A operator. If neither the A operator is set, None is returned.
Returns
returns the current Q factory of the algorithm
Return type
QFactory
quantum_instance
Type: Union[None, qiskit.aqua.quantum_instance.QuantumInstance]
Returns quantum instance.
Return type
Optional
[QuantumInstance
]
random
Return a numpy random.
Methods
confidence_interval
MaximumLikelihoodAmplitudeEstimation.confidence_interval(alpha, kind='fisher')
Compute the alpha confidence interval using the method kind.
The confidence level is (1 - alpha) and supported kinds are ‘fisher’, ‘likelihood_ratio’ and ‘observed_fisher’ with shorthand notations ‘fi’, ‘lr’ and ‘oi’, respectively.
Parameters
- alpha (
float
) – The confidence level. - kind (
str
) – The method to compute the confidence interval. Defaults to ‘fisher’, which computes the theoretical Fisher information.
Return type
List
[float
]
Returns
The specified confidence interval.
Raises
- AquaError – If run() hasn’t been called yet.
- NotImplementedError – If the method kind is not supported.
construct_circuits
MaximumLikelihoodAmplitudeEstimation.construct_circuits(measurement=False)
Construct the Amplitude Estimation w/o QPE quantum circuits.
Parameters
measurement (bool
) – Boolean flag to indicate if measurement should be included in the circuits.
Return type
List
[QuantumCircuit
]
Returns
A list with the QuantumCircuit objects for the algorithm.
run
MaximumLikelihoodAmplitudeEstimation.run(quantum_instance=None, **kwargs)
Execute the algorithm with selected backend.
Parameters
- quantum_instance (
Union
[QuantumInstance
,BaseBackend
,None
]) – the experimental setting. - kwargs (dict) – kwargs
Returns
results of an algorithm.
Return type
dict
Raises
AquaError – If a quantum instance or backend has not been provided
set_backend
MaximumLikelihoodAmplitudeEstimation.set_backend(backend, **kwargs)
Sets backend with configuration.
Return type
None