Skip to content

Instantly share code, notes, and snippets.

@techyugadi
Last active June 28, 2021 17:53
Show Gist options
  • Save techyugadi/1217c16c37d889b4d2204dff067388b2 to your computer and use it in GitHub Desktop.
Save techyugadi/1217c16c37d889b4d2204dff067388b2 to your computer and use it in GitHub Desktop.
Examples of modelling Covid-19 infections using covimath Python package

Examples of using python package: covimath

This gist shows how to use the open source package covimath.

Generating an SIR model

from covimath.models import sir

def trySIR(N, beta, gamma, I0, R0, tau):
    model = sir.SIR(N=N, beta=beta, gamma=gamma, I0=I0, R0=R0, tau=tau)
    model.solve()
    model.plot()

if __name__ == "__main__":
    trySIR(1000, 0.2, 0.1, 1, 0, 150)

Estimating beta for SIR model

import numpy as np
from covimath.paramest import sirparams

def paramtest():
    ni = np.array([5, 7, 11, 20, 30, 45, 75, 115, 155,
                   220, 315, 540, 720, 950])
    _beta = sirparams.findbeta(ni)
    print(_beta)

if __name__ == "__main__":
    paramtest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment