Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MarkovProcesses.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bentriou Mahmoud
MarkovProcesses.jl
Commits
5d8c423e
Commit
5d8c423e
authored
4 years ago
by
Bentriou Mahmoud
Browse files
Options
Downloads
Patches
Plain Diff
fix in plots of third notebook
parent
ed3f850c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/notebooks/3_ABC-SMC_with_ContinuousTimeModel.ipynb
+9
-1
9 additions, 1 deletion
examples/notebooks/3_ABC-SMC_with_ContinuousTimeModel.ipynb
with
9 additions
and
1 deletion
examples/notebooks/3_ABC-SMC_with_ContinuousTimeModel.ipynb
+
9
−
1
View file @
5d8c423e
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
"parametric_SIR = ParametricModel(SIR, (:ki, Uniform(0.001, 0.0015)))\n",
"parametric_SIR = ParametricModel(SIR, (:ki, Uniform(0.001, 0.0015)))\n",
"\n",
"\n",
"vec_observations = [simulate(SIR)]\n",
"vec_observations = [simulate(SIR)]\n",
"\n",
"function dist_obs(vec_sim::Vector{Trajectory}, vec_observations::Vector{Trajectory})\n",
"function dist_obs(vec_sim::Vector{Trajectory}, vec_observations::Vector{Trajectory})\n",
" return dist_lp(vec_sim[1], vec_observations[1]; p=2)\n",
" return dist_lp(vec_sim[1], vec_observations[1]; p=2)\n",
"end\n",
"end\n",
...
@@ -40,8 +41,15 @@
...
@@ -40,8 +41,15 @@
"outputs": [],
"outputs": [],
"source": [
"source": [
"using Plots\n",
"using Plots\n",
"histogram(res_abc.mat_p_end, weights = res_abc.weights
_end
)"
"histogram(
vec(
res_abc.mat_p_end
)
, weights = res_abc.weights)"
]
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
}
],
],
"metadata": {
"metadata": {
...
...
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# ABC-SMC with ContinuousTimeModel
# ABC-SMC with ContinuousTimeModel
The package allows the run of ABC-SMC algorithm with models defined by the package.
The package allows the run of ABC-SMC algorithm with models defined by the package.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
julia
```
julia
using
MarkovProcesses
using
MarkovProcesses
using
Distributions
using
Distributions
load_model
(
"SIR"
)
load_model
(
"SIR"
)
set_time_bound!
(
SIR
,
100.0
)
set_time_bound!
(
SIR
,
100.0
)
parametric_SIR
=
ParametricModel
(
SIR
,
(
:
ki
,
Uniform
(
0.001
,
0.0015
)))
parametric_SIR
=
ParametricModel
(
SIR
,
(
:
ki
,
Uniform
(
0.001
,
0.0015
)))
vec_observations
=
[
simulate
(
SIR
)]
vec_observations
=
[
simulate
(
SIR
)]
function
dist_obs
(
vec_sim
::
Vector
{
Trajectory
},
vec_observations
::
Vector
{
Trajectory
})
function
dist_obs
(
vec_sim
::
Vector
{
Trajectory
},
vec_observations
::
Vector
{
Trajectory
})
return
dist_lp
(
vec_sim
[
1
],
vec_observations
[
1
];
p
=
2
)
return
dist_lp
(
vec_sim
[
1
],
vec_observations
[
1
];
p
=
2
)
end
end
epsilon
=
0.5
*
dist_obs
([
simulate
(
SIR
)],
vec_observations
)
epsilon
=
0.5
*
dist_obs
([
simulate
(
SIR
)],
vec_observations
)
@show
epsilon
@show
epsilon
res_abc
=
abc_smc
(
parametric_SIR
,
vec_observations
,
dist_obs
,
nbr_particles
=
100
,
tolerance
=
epsilon
)
res_abc
=
abc_smc
(
parametric_SIR
,
vec_observations
,
dist_obs
,
nbr_particles
=
100
,
tolerance
=
epsilon
)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
julia
```
julia
using
Plots
using
Plots
histogram
(
res_abc
.
mat_p_end
,
weights
=
res_abc
.
weights_end
)
histogram
(
vec
(
res_abc
.
mat_p_end
),
weights
=
res_abc
.
weights
)
```
%% Cell type:code id: tags:
```
julia
```
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment