Commit 7f7673ec authored by Leo Gao's avatar Leo Gao
Browse files

Add comment

parent 59aff21d
......@@ -175,6 +175,12 @@ def _sacreformat(refs, preds):
def bootstrap_stderr(f, xs, iters=100000):
# this gives a biased estimate of the stderr (i.e w/ the mean, it gives something
# equivalent to stderr calculated without Bessel's correction in the stddev.
# Unfortunately, I haven't been able to figure out what the right correction is
# to make the bootstrap unbiased - i considered multiplying by sqrt(n/(n-1)) but
# that would be ad-hoc and I can't prove that that would actually be an unbiased estimator)
# Thankfully, shouldn't matter because our samples are pretty big usually anyways
rnd = random.Random()
rnd.seed(42)
res = []
......
......@@ -7,6 +7,6 @@ def test_bootstrapping():
random.seed(42)
arr = [random.random() for _ in range(1000)]
expected = metrics.mean_stderr(arr)
bootstrapped = metrics.bootstrap_stderr(metrics.mean, arr, iters=100000)
bootstrapped = metrics.bootstrap_stderr(metrics.mean, arr)
assert bootstrapped == pytest.approx(expected, abs=1e-4)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment