Giter Site home page Giter Site logo

fsucilab / sir-julia Goto Github PK

View Code? Open in Web Editor NEW

This project forked from epirecipes/sir-julia

0.0 1.0 0.0 12.2 MB

Various implementations of the classical SIR model in Julia

License: MIT License

HTML 98.87% Julia 0.35% Smarty 0.02% CSS 0.13% Jupyter Notebook 0.62%

sir-julia's Introduction

sir-julia

Various implementations of the classical SIR model in Julia

Try the notebooks out in Binder:

Binder

Model considered

GitHub Markdown doesn't parse equations, so here's a description of the underlying SIR model.

  • The ordinary differential equation model considers:
    • Susceptible, S, with initial condition S(0)=990
    • Infected, I, with initial condition, I(0)=10
    • Recovered, R, with initial condition R(0)=10
    • Total population, N=S+I+R=1000
  • Susceptible individuals make contacts with others at rate c (=10.0), with the probability of a contact with an infectious person being I/N. With probability β (=0.05), an infected person will infect a susceptible given a contact.
  • Infected individuals recover at a per-capita rate γ (=0.25).

Simulation with different types of model

The above process can be represented in different kinds of ways:

Inference

In addition to the above examples of simulation, there are also examples of inference of the parameters of the model using counts of new cases. Although these are toy examples, they provide the building blocks for more complex situations.

Comments on implementations

Note that the implementations and choice of parameters may be suboptimal, and are intended to illustrate more-or-less the same underlying biological process with different mathematical representations. Additional optimizations may be obtained e.g. by using StaticArrays.

I've also tried to transform parameterisations in discrete time as closely as possible to their continuous counterparts. Please see the great work by Linda Allen for how these different representations compare.

Types of output

Thanks to Weave.jl, Julia Markdown files (in tutorials/) are converted into multiple formats.

Running notebooks

git clone https://github.com/epirecipes/sir-julia
cd sir-julia

Then launch julia and run the following.

cd(@__DIR__)
import IJulia
IJulia.notebook(;dir="notebook")

Adding new examples

To add an example, make a new subdirectory in the tutorials directory, and add a Julia Markdown (.jmd) document to it. Set the beginning to something like the following:

# Agent-based model using Agents.jl
Simon Frost (@sdwfrost), 2020-04-27

Suggested sections:

  • Introduction
  • Libraries
  • Utility functions
  • Transitions
  • Time domain
  • Initial conditions
  • Parameter values
  • Random number seed
  • Running the model
  • Post-processing
  • Plotting
  • Benchmarking

In addition, an appendix that displays the machine on which the code is run, and the package details,{} can be added using the following code:

include(joinpath(@__DIR__,"tutorials","appendix.jl"))
appendix()

Change to the root directory of the repository and run the following from within Julia.

include("build.jl")
weave_all()

Acknowledgements

Examples use the following libraries:

Parts of the code were taken from @ChrisRackauckas DiffEqTutorials, which comes highly recommended.

sir-julia's People

Contributors

sdwfrost avatar chrisrackauckas avatar erlebach avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.