コード例 #1
0
    def test_isWhite(self):
        notwhite = Correlator([.1] * 100)
        assert not notwhite.isWhite('mehra')
        assert not notwhite.isWhite('ljung-box')

        white = Correlator([0] * 50 + [1] + [0] * 50)
        assert white.isWhite('mehra')
        assert white.isWhite('ljung-box')

        with pytest.raises(ValueError):
            white.isWhite('novalidmethod')
コード例 #2
0
ファイル: correlator.py プロジェクト: gumpfly/noiseestimation
from numpy.random import randn
from noiseestimation.correlator import Correlator

num_runs = 50
arr_length = 200

num_mehra_white = 0
num_ljungbox_white = 0
for i in range(num_runs):
    seq = randn(arr_length)
    cor = Correlator(seq)

    if cor.isWhite():
        num_ljungbox_white += 1
    if cor.isWhite('mehra'):
        num_mehra_white += 1

print("-" * 10)
print("%d / %d white (%.3f %%) using Mehra method" %
      (num_mehra_white, num_runs, 100 * float(num_mehra_white) / num_runs))
print(
    "%d / %d white (%.3f %%) using Ljund-Box method" %
    (num_ljungbox_white, num_runs, 100 * float(num_ljungbox_white) / num_runs))