{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "using Plots\n", "gr()\n", "using DelimitedFiles" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "EVDdata = DelimitedFiles.readdlm(\"wikipediaEVDdatesconverted.csv\", ',')\n", "tvalsfromdata = EVDdata[:,1] \n", "totalcasesfromdata = EVDdata[:,2];" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "updateSIR (generic function with 1 method)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function updateSIR(popnvector)\n", " susceptibles = popnvector[1];\n", " infecteds = popnvector[2];\n", " removeds = popnvector[3];\n", " newS = susceptibles - λ*susceptibles*infecteds*dt\n", " newI = infecteds + λ*susceptibles*infecteds*dt - γ*infecteds*dt\n", " newR = removeds + γ*infecteds*dt\n", " return [newS newI newR]\n", "end" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "# Values for the test run\n", "λ = 1.47*10^-6 #0.0005\n", "γ = 0.125\n", "dt = 0.5\n", "tfinal = 610\n", "s0 = 1.0*10^5 #150.0\n", "i0 = 20.\n", "r0 = 0.0;\n" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "nsteps = round(Int64,tfinal/dt)\n", "resultvals = Array{Float64}(undef,nsteps+1,3)\n", "timevec = Array{Float64}(undef,nsteps+1)\n", "resultvals[1,:] = [s0, i0, r0]\n", "timevec[1] = 0.;" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "for step = 1:nsteps\n", " resultvals[step+1,:] = updateSIR(resultvals[step,:])\n", " timevec[step+1] = timevec[step] + dt\n", "end" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "ivals = resultvals[:,2];\n", "rvals = resultvals[:,3];\n", "cvals = ivals + rvals;" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" }, { "name": "stderr", "output_type": "stream", "text": [ "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n", "GKS: character ignored due to unicode error\n" ] } ], "source": [ "plot(timevec,cvals,\n", " label = \"Model Values\",\n", " xlabel = \"Epidemic Day\",\n", " ylabel = \"Number of cases to date\",\n", " title = \"Model vs Data\"\n", ")\n", "\n", "plot!(tvalsfromdata,totalcasesfromdata,\n", " legend=:right,\n", " line=:scatter,\n", " label=\"Reported number of cases\"\n", ")" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f(x) = 5 * x^2 + 3 * x - 20\n", "plot(f, -10:10) " ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot!(zero,-10,10)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "f (generic function with 1 method)" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f(x) = -9*x^2 + 3*x + 6" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot(f,-2,2)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot(f)" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot(f,-2:2)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot(-2,2,f)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Julia 1.2.0", "language": "julia", "name": "julia-1.2" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.2.0" } }, "nbformat": 4, "nbformat_minor": 4 }