"inits" is the method to use
@@ -23,7 +23,6 @@ from scipy.stats import norm, chi2
from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit
from qiskit.aqua import AquaError
from qiskit.aqua import Pluggable, PluggableType, get_pluggable_class
-from qiskit.aqua.algorithms import QuantumAlgorithm
from .ae_base import AmplitudeEstimationBase
@@ -187,11 +186,7 @@ class AmplitudeEstimationWithoutQPE(AmplitudeEstimationBase):
MLE for a statevector simulation
"""
probs = self._evaluate_statevectors(self._ret['statevectors'])
- # TODO: replace by more efficient and numerically stable implementation
- method = "inits"
-
- if method == "inits":
search_range = [0, np.pi / 2]
init = np.mean(search_range)
best_theta = None
@@ -270,7 +265,7 @@ class AmplitudeEstimationWithoutQPE(AmplitudeEstimationBase):
return default
return np.max(array)
- def compute_lr_ci(self, alpha=0.05, nevals=10000):
+ def _likelihood_ratio_ci(self, alpha=0.05, nevals=10000):
"""
Compute the likelihood-ratio confidence interval.
@@ -321,7 +316,7 @@ class AmplitudeEstimationWithoutQPE(AmplitudeEstimationBase):
return mapped_ci_outer, mapped_ci_inner
- def compute_fisher_ci(self, alpha=0.05, observed=False):
+ def _fisher_ci(self, alpha=0.05, observed=False):
"""
Compute the alpha confidence interval based on the Fisher information
@@ -402,6 +397,22 @@ class AmplitudeEstimationWithoutQPE(AmplitudeEstimationBase):
return fisher_information
+ def confidence_interval(self, alpha, kind='fisher'):
+ # check if AE did run already
+ if 'mle' not in self._ret.keys():
+ raise AquaError('Call run() first!')
+
+ if kind in ['likelihood_ratio', 'lr']:
+ return self._likelihood_ratio_ci(alpha)
+
+ if kind in ['fisher', 'fi']:
+ return self._fisher_ci(alpha, observed=False)
+
+ if kind in ['observed_fisher', 'observed_information', 'oi']:
+ return self._fisher_ci(alpha, observed=True)
+
+ raise NotImplementedError(f'CI `{kind}` is not implemented.')
+
def _run(self):
self.check_factories()
