def test_large_x(self): # for large values of x and n, the series used to compute the cdf # converges slowly. # this leads to bug in R package goftest and MAPLE code that is # the basis of the implemenation in scipy # note: cdf = 1 for x >= 1000/3 and n = 1000 assert_(0.99999 < _cdf_cvm(333.3, 1000) < 1.0) assert_(0.99999 < _cdf_cvm(333.3) < 1.0)
def test_low_p(self): # _cdf_cvm can return values larger than 1. In that case, we just # return a p-value of zero. n = 12 res = cramervonmises(np.ones(n) * 0.8, 'norm') assert_(_cdf_cvm(res.statistic, n) > 1.0) assert_equal(res.pvalue, 0)
def test_cdf_support(self): # cdf has support on [1/(12*n), n/3] assert_equal(_cdf_cvm([1 / (12 * 533), 533 / 3], 533), [0, 1]) assert_equal(_cdf_cvm([1 / (12 * (27 + 1)), (27 + 1) / 3], 27), [0, 1])
def test_cdf_inf(self): assert_allclose(_cdf_cvm([0.02480, 0.03656, 0.11888, 1.16204]), [0.01, 0.05, 0.5, 0.999], atol=1e-4)
def test_cdf_1000(self): assert_allclose(_cdf_cvm([0.02481, 0.03658, 0.11889, 1.16120], 1000), [0.01, 0.05, 0.5, 0.999], atol=1e-4)
def test_cdf_10(self): assert_allclose(_cdf_cvm([0.02657, 0.03830, 0.12068, 0.56643], 10), [0.01, 0.05, 0.5, 0.975], atol=1e-4)
def test_cdf_4(self): assert_allclose(_cdf_cvm([0.02983, 0.04111, 0.12331, 0.94251], 4), [0.01, 0.05, 0.5, 0.999], atol=1e-4)
def test_cdf_large_n(self): # test that asymptotic cdf and cdf for large samples are close assert_allclose(_cdf_cvm([0.02480, 0.03656, 0.11888, 1.16204, 100], 10000), _cdf_cvm([0.02480, 0.03656, 0.11888, 1.16204, 100]), atol=1e-4)