Skip to content

Commit

Permalink
test_simulate_ergodicity added
Browse files Browse the repository at this point in the history
test_simulate_lln replaced by test_mc_sample_path_lln
  • Loading branch information
oyamad committed Aug 8, 2015
1 parent 0387534 commit 241193b
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions quantecon/markov/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,19 @@ def test_simulate_shape():
(num_reps, ts_length))


def test_simulate_lln():
def test_simulate_ergodicity():
P = [[0.4, 0.6], [0.2, 0.8]]
stationary_dist = [0.25, 0.75]
init = 0
mc = MarkovChain(P)

seed = 34
ts_length = 10**4
tol = 0.02
seed = 4433
ts_length = 100
num_reps = 300
tol = 0.1

frequency_1 = mc.simulate(ts_length, random_state=seed).mean()
x = mc.simulate(ts_length, init=init, num_reps=num_reps, random_state=seed)
frequency_1 = x[:, -1].mean()
ok_(np.abs(frequency_1 - stationary_dist[1]) < tol)


Expand Down Expand Up @@ -290,6 +293,20 @@ def test_mc_sample_path():
assert_array_equal(computed, expected)


def test_mc_sample_path_lln():
P = [[0.4, 0.6], [0.2, 0.8]]
stationary_dist = [0.25, 0.75]
init = 0

seed = 4433
sample_size = 10**4
tol = 0.02

frequency_1 = mc_sample_path(P, init=init, sample_size=sample_size,
random_state=seed).mean()
ok_(np.abs(frequency_1 - stationary_dist[1]) < tol)


@raises(ValueError)
def test_raises_value_error_non_2dim():
"""Test with non 2dim input"""
Expand Down

0 comments on commit 241193b

Please sign in to comment.