Пример #1
0
def test_randomize(rng):
    a = SemanticPointer(100, rng=rng)
    std = np.std(a.v)
    assert np.allclose(std, 1.0 / np.sqrt(len(a)), rtol=0.02)

    a = SemanticPointer(100)
    a.randomize(rng=rng)
    assert len(a) == 100
    std = np.std(a.v)
    assert np.allclose(std, 1.0 / np.sqrt(len(a)), rtol=0.02)

    a = SemanticPointer(5)
    a.randomize(N=100, rng=rng)
    assert len(a) == 100
    std = np.std(a.v)
    assert np.allclose(std, 1.0 / np.sqrt(len(a)), rtol=0.02)
Пример #2
0
def test_randomize(rng):
    a = SemanticPointer(100, rng=rng)
    std = np.std(a.v)
    assert np.allclose(std, 1.0 / np.sqrt(len(a)), rtol=0.02)

    a = SemanticPointer(100)
    a.randomize(rng=rng)
    assert len(a) == 100
    std = np.std(a.v)
    assert np.allclose(std, 1.0 / np.sqrt(len(a)), rtol=0.02)

    a = SemanticPointer(5)
    a.randomize(N=100, rng=rng)
    assert len(a) == 100
    std = np.std(a.v)
    assert np.allclose(std, 1.0 / np.sqrt(len(a)), rtol=0.02)