Skip to content

Commit 86e4338

Browse files
committed
FIX: bug of computing state values in the last period of LQMarkov model
1 parent 15b3b93 commit 86e4338

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

quantecon/lqcontrol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,6 @@ def compute_sequence(self, x0, ts_length=None, random_state=None):
605605
u_path[:, t] = - (Fs[state[t]] @ x_path[:, t])
606606
Ax = As[state[T]] @ x_path[:, T-1]
607607
Bu = Bs[state[T]] @ u_path[:, T-1]
608-
x_path[:, T] = Ax + Bu + w_path[:, T]
608+
x_path[:, T] = Ax + Bu + Cw_path[:, T]
609609

610610
return x_path, u_path, w_path, state

quantecon/tests/test_lqcontrol.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class TestLQMarkov(unittest.TestCase):
9595

9696
def setUp(self):
9797

98-
# Markove chain transition matrix
98+
# Markov chain transition matrix
9999
Π = np.array([[0.8, 0.2],
100100
[0.2, 0.8]])
101101

@@ -153,7 +153,7 @@ def test_scalar_sequences_with_seed(self):
153153
lq_markov_scalar = self.lq_markov_scalar
154154
x0 = 2
155155

156-
expected_x_seq = np.array([[2., 1.15977567, 1.20677567]])
156+
expected_x_seq = np.array([[2., 1.15977567, 0.6725398]])
157157
expected_u_seq = np.array([[1.28044866, 0.7425166]])
158158
expected_w_seq = np.array([[1.3486939, 0.55721062, 0.53423587]])
159159
expected_state = np.array([1, 1, 1])
@@ -188,8 +188,8 @@ def test_mat_sequences(self):
188188
lq_markov_mat = self.lq_markov_mat1
189189
x0 = np.array([[1000, 1, 25]])
190190

191-
expected_x_seq = np.array([[1.00000000e+03, 1.01490556e+03],
192-
[1.00000000e+00, 2.18454431e+00],
191+
expected_x_seq = np.array([[1.00000000e+03, 1.01372101e+03],
192+
[1.00000000e+00, 1.00000000e+00],
193193
[2.50000000e+01, 2.61845443e+01]])
194194
expected_u_seq = np.array([[1013.72101253]])
195195
expected_w_seq = np.array([[0.41782708, 1.18454431]])

0 commit comments

Comments
 (0)