Exemplo n.º 1
0
def test_histogram():
    a, b = 0.3, 3.14
    s = np.random.uniform(a, b, 10000) % 1

    b, w = kuiper.fold_intervals([(a, b, 1. / (b - a))])

    h = kuiper.histogram_intervals(16, b, w)
    nn, bb = np.histogram(s, bins=len(h), range=(0, 1), new=True)

    uu = np.sqrt(nn)
    nn, uu = len(h) * nn / h / len(s), len(h) * uu / h / len(s)

    c2 = np.sum(((nn - 1) / uu)**2)

    assert scipy.stats.chi2(len(h)).cdf(c2) > 0.01
    assert scipy.stats.chi2(len(h)).sf(c2) > 0.01
Exemplo n.º 2
0
def test_histogram():
    a, b = 0.3, 3.14
    s = np.random.uniform(a,b,10000) % 1
    
    b, w = kuiper.fold_intervals([(a,b,1./(b-a))])

    h = kuiper.histogram_intervals(16,b,w)
    nn, bb = np.histogram(s, bins=len(h), range=(0,1), new=True)

    uu = np.sqrt(nn)
    nn, uu = len(h)*nn/h/len(s), len(h)*uu/h/len(s)

    c2 = np.sum(((nn-1)/uu)**2)
    
    assert scipy.stats.chi2(len(h)).cdf(c2)>0.01
    assert scipy.stats.chi2(len(h)).sf(c2)>0.01
Exemplo n.º 3
0
def test_fold_intervals():
    b, w = kuiper.fold_intervals([(0, 0.1, 1), (0.05, 3, 0.1)])
    assert_array_almost_equal(b, [0, 0.05, 0.1, 1])
    assert_array_almost_equal(w, [1.2, 1.3, 0.3])
Exemplo n.º 4
0
def test_weighted():
    a = (np.random.random(100) * 3.4 + 0.8) % 1
    i = (0.8, 4.2, 1)
    b, t = kuiper.fold_intervals([i])
    cdf = kuiper.cdf_from_intervals(b, t)
    assert kuiper.kuiper(a, cdf)[1] > 0.01
Exemplo n.º 5
0
def test_weighted():
    a = (np.random.random(100) * 3.4 + 0.8)%1
    i = (0.8,4.2,1)
    b, t = kuiper.fold_intervals([i])
    cdf = kuiper.cdf_from_intervals(b,t)
    assert kuiper.kuiper(a,cdf)[1]>0.01
Exemplo n.º 6
0
def test_fold_intervals():
    b, w = kuiper.fold_intervals([(0,0.1,1),(0.05,3,0.1)])
    assert_array_almost_equal(b, [0,0.05,0.1,1])
    assert_array_almost_equal(w, [1.2,1.3,0.3])