Пример #1
0
 def test_seeded_run(self):
     random.seed(1)
     m = AR(c=1, sigma=1, pcoeff=[1, -1, 0.5])
     x = m.generate(10)
     expected = [
         2.28818475, 4.73763036, 3.51578142, 0.15769978, -1.08143967,
         1.55008577, 2.68827216, 0.16063711, -0.55328019, 1.76359339
     ]
     assert x == pytest.approx(expected)
Пример #2
0
 def test_periodic(self):
     m = AR(c=1, sigma=0, pcoeff=[1, -1])
     x = m.generate(10)
     assert x == [1.0, 2.0, 2.0, 1.0, 0.0, 0.0, 1.0, 2.0, 2.0, 1.0]
Пример #3
0
 def test_white_noise(self):
     m = AR(c=0, sigma=1, pcoeff=[])
     s = pd.Series(m.generate(1000))
     assert s.std() == pytest.approx(1.0, abs=1e2)
     assert s.mean() == pytest.approx(0.0, abs=1e2)
Пример #4
0
 def test_linear_using_buffer(self):
     m = AR(c=1, sigma=0, pcoeff=[1], x_buff=[4])
     x = m.generate(10)
     assert x == [float(x) for x in range(5, 15)]
Пример #5
0
 def test_linear_multiple_calls(self):
     m = AR(c=1, sigma=0, pcoeff=[1])
     x = m.generate(10)
     assert x == [float(x) for x in range(1, 11)]
     x = m.generate(10)
     assert x == [float(x) for x in range(11, 21)]
Пример #6
0
 def test_linear(self):
     m = AR(c=1, sigma=0, pcoeff=[1])
     x = m.generate(10)
     assert x == [float(x) for x in range(1, 11)]
Пример #7
0
 def test_constant_generation(self):
     m = AR(c=1, sigma=0)
     x = m.generate(10)
     assert x == [1] * 10