Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
p
Precision of candidate anchor
level
beta / nb of samples
n_iter
Number of iterations during lower bound update
Returns
-------
Updated lower precision bound
"""
um = p
lm = max(min(1, p - np.sqrt(level / 2.)), 0) # lower bound
for j in range(1, n_iter):
qm = (um + lm) / 2.
if AnchorBaseBeam.kl_bernoulli(p, qm) > level: # KL-divergence > threshold level
lm = qm
else:
um = qm
return lm
Precision of candidate anchor
level
beta / nb of samples
n_iter
Number of iterations during lower bound update
Returns
-------
Updated upper precision bound
"""
# TODO: where does 17x sampling come from?
lm = p
um = min(min(1, p + np.sqrt(level / 2.)), 1)
for j in range(1, n_iter):
qm = (um + lm) / 2.
if AnchorBaseBeam.kl_bernoulli(p, qm) > level:
um = qm
else:
lm = qm
return um