def test_stratKP2iS_1D_additive(): tspan = np.arange(0.0, 2000.0, 0.002) y0 = 0.0 f = lambda y, t: -1.0 * y G = lambda y, t: 0.2 y = sdeint.stratKP2iS(f, G, y0, tspan) assert (np.isclose(np.mean(y), 0.0, rtol=0, atol=1e-02)) assert (np.isclose(np.var(y), 0.2 * 0.2 / 2, rtol=1e-01, atol=0))
def test_stratKP2iS_1D_additive(): tspan = np.arange(0.0, 2000.0, 0.002) y0 = 0.0 f = lambda y, t: -1.0 * y G = lambda y, t: 0.2 y = sdeint.stratKP2iS(f, G, y0, tspan) assert(np.isclose(np.mean(y), 0.0, rtol=0, atol=1e-02)) assert(np.isclose(np.var(y), 0.2*0.2/2, rtol=1e-01, atol=0))
def test_stratKP2iS_R74(self, exact_solution_R74): (dW, I, J, f, f_strat, G, G_separate, y0, tspan, y) = exact_solution_R74 yKP2iS = sdeint.stratKP2iS(f_strat, G, y0, tspan, dW=dW, J=J) _assert_close(yKP2iS, y, 1e-1, 1e-1) return yKP2iS
def test_stratKP2iS_KPS445(self, exact_solution_KPS445): (dW, I, J, f, f_strat, G, y0, tspan, y) = exact_solution_KPS445 yKP2iS = sdeint.stratKP2iS(f_strat, G, y0, tspan, dW=dW, J=J)[:, 0] _assert_close(yKP2iS, y, 1e-1, 1e-1) return yKP2iS
def test_stratKP2iS_R74(self, exact_solution_R74): (dW, I, J, f, f_strat, G, G_separate, y0, tspan,y) = exact_solution_R74 yKP2iS = sdeint.stratKP2iS(f_strat, G, y0, tspan, dW=dW, J=J) _assert_close(yKP2iS, y, 1e-1, 1e-1) return yKP2iS
def test_stratKP2iS_KPS445(self, exact_solution_KPS445): (dW, I, J, f, f_strat, G, y0, tspan, y) = exact_solution_KPS445 yKP2iS = sdeint.stratKP2iS(f_strat, G, y0, tspan, dW=dW, J=J)[:,0] _assert_close(yKP2iS, y, 1e-1, 1e-1) return yKP2iS