dist_case_2.jl 1.32 KB
 Bentriou Mahmoud committed Nov 18, 2020 1 2 3 4 5 6 `````` using MarkovProcesses import QuadGK: quadgk load_model("SIR") test_all = true `````` Bentriou Mahmoud committed Nov 18, 2020 7 ``````p=2 `````` Bentriou Mahmoud committed Nov 18, 2020 8 9 10 11 12 13 ``````for p = 1:2 res = (4-1)^p * 0.5 + (4-2)^p * 0.1 + 0 + (5-3)^p * 0.1 + (5-1)^p * (1.4 - 0.8) + (3-1)^p * (3.0-1.4) res = res^(1/p) y_obs = [1, 2, 5, 3, 3] t_y = [0.0, 0.5, 0.7, 1.4, 3.0] `````` Bentriou Mahmoud committed Nov 23, 2020 14 15 `````` values = [zeros(length(y_obs))] values[1] = y_obs `````` Bentriou Mahmoud committed Nov 18, 2020 16 17 18 19 20 `````` l_tr = Vector{Nothing}(nothing, length(y_obs)) σ2 = Trajectory(SIR, values, t_y, l_tr) x_obs = [4, 2, 3, 1, 1] t_x = [0.0, 0.6, 0.7, 0.8, 3.0] `````` Bentriou Mahmoud committed Nov 23, 2020 21 22 `````` values = [zeros(length(x_obs))] values[1] = x_obs `````` Bentriou Mahmoud committed Nov 18, 2020 23 24 25 `````` l_tr = Vector{Nothing}(nothing, length(x_obs)) σ1 = Trajectory(SIR, values, t_x, l_tr) `````` Bentriou Mahmoud committed Nov 23, 2020 26 `````` test_1 = isapprox(dist_lp(x_obs, t_x, y_obs, t_y; p=p), res; atol = 1E-10) `````` Bentriou Mahmoud committed Nov 18, 2020 27 `````` test_1 = test_1 && isapprox(dist_lp(σ1,σ2; p=p), res; atol = 1E-10) `````` Bentriou Mahmoud committed Nov 23, 2020 28 `````` test_1_bis = isapprox(dist_lp(y_obs, t_y, x_obs, t_x; p=p), res; atol = 1E-10) `````` Bentriou Mahmoud committed Nov 18, 2020 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 `````` test_1_bis = test_1_bis && isapprox(dist_lp(σ2,σ1; p=p), res; atol = 1E-10) f_x(t::Real) = MarkovProcesses._f_step(x_obs, t_x, t) f_y(t::Real) = MarkovProcesses._f_step(y_obs, t_y, t) diff_f(t) = abs(f_x(t) - f_y(t))^p int, err = quadgk(diff_f, 0.0, 3.0) res_int = int^(1/p) test_2 = isapprox(res, res_int; atol = err) global test_all = test_all && test_1 && test_1_bis && test_2 end return test_all ``````