def setUp(self): self.rho, self.sigma = np.random.uniform(0, 1, size=2) self.n = np.random.random_integers(3, 25) self.ybar = np.random.random_integers(0, 10) self.tol = 1e-10 mc = rouwenhorst(self.n, self.ybar, self.sigma, self.rho) self.x, self.P = mc.state_values, mc.P
def setUp(self): self.rho, self.sigma = np.random.uniform(0, 1, size=2) self.n = np.random.random_integers(3, 25) self.ybar = np.random.random_integers(0, 10) self.tol = 1e-12 mc = rouwenhorst(self.n, self.ybar, self.sigma, self.rho) self.x, self.P = mc.state_values, mc.P
def setup(self): self.rho, self.sigma = np.random.uniform(0, 1, size=2) self.n = np.random.randint(3, 26) self.ybar = np.random.randint(0, 11) self.tol = 1e-10 mc = rouwenhorst(self.n, self.ybar, self.sigma, self.rho) self.x, self.P = mc.state_values, mc.P
def test_control_case(self): n = 3; ybar = 1; sigma = 0.5; rho = 0.8; mc_rouwenhorst = rouwenhorst(n, ybar, sigma, rho) mc_rouwenhorst.x, mc_rouwenhorst.P = mc_rouwenhorst.state_values, mc_rouwenhorst.P sigma_y = np.sqrt(sigma**2 / (1-rho**2)) psi = sigma_y * np.sqrt(n-1) known_x = np.array([-psi+5.0, 5., psi+5.0]) known_P = np.array([[0.81, 0.18, 0.01], [0.09, 0.82, 0.09], [0.01, 0.18, 0.81]]) self.assertTrue(sum(mc_rouwenhorst.x - known_x) < self.tol and sum(sum(mc_rouwenhorst.P - known_P)) < self.tol)