def test_uniform_binomial(N, m, p): """Check that the false positive probability is right In particular, run m trials with N uniformly-distributed photons and check that the number of false positives is consistent with a binomial distribution. The more trials, the tighter the bounds but the longer the runtime. """ with NumpyRNGContext(1234): fpps = np.array( [funcs.kuiper(np.random.random(N))[1] for i in range(m)]) assert (fpps >= 0).all() assert (fpps <= 1).all() low = scipy.stats.binom(n=m, p=p).ppf(0.01) high = scipy.stats.binom(n=m, p=p).ppf(0.99) assert (low < sum(fpps < p) < high)
def test_uniform_binomial(N, m, p): """Check that the false positive probability is right In particular, run m trials with N uniformly-distributed photons and check that the number of false positives is consistent with a binomial distribution. The more trials, the tighter the bounds but the longer the runtime. """ with NumpyRNGContext(1234): fpps = np.array([funcs.kuiper(np.random.random(N))[1] for i in range(m)]) assert (fpps >= 0).all() assert (fpps <= 1).all() low = scipy.stats.binom(n=m, p=p).ppf(0.01) high = scipy.stats.binom(n=m, p=p).ppf(0.99) assert (low < sum(fpps < p) < high)
def test_uniform(N): with NumpyRNGContext(12345): assert funcs.kuiper(np.random.random(N))[1] > 0.01