{"id":10264,"date":"2018-11-02T09:05:56","date_gmt":"2018-11-02T13:05:56","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=10264"},"modified":"2018-11-02T09:05:56","modified_gmt":"2018-11-02T13:05:56","slug":"zombie-outbreak","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2018\/11\/02\/zombie-outbreak\/","title":{"rendered":"Zombie Outbreak"},"content":{"rendered":"<div xmlns:mwsh=\"http:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\n   <introduction><\/p>\n<p><a href=\"http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495\">Sean<\/a>&#8216;s pick this week is <a href=\"http:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/54368\">Mathematical modelling of an outbreak of zombie infection<\/a> by <a href=\"http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/4608373\">E. Cheynet<\/a>.\n      <\/p>\n<p>   <\/introduction><\/p>\n<p>In honor of Halloween, E. has provided us with a way to simulate zombie outbreaks!  Do you have what it takes to save humanity?<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">Npop = 500; <span style=\"color: #228B22\">% population<\/span>\r\nalpha = 7.5e-3 ; <span style=\"color: #228B22\">%  \"zombie destruction\" rate.<\/span>\r\nbeta = 5e-3; <span style=\"color: #228B22\">% \"zombie creation\" rate.<\/span>\r\nzeta = 9.2e-2; <span style=\"color: #228B22\">% zombie resurrection rate<\/span>\r\ndelta = 1.2e-4; <span style=\"color: #228B22\">% susceptibles death rate<\/span>\r\ntmax = 100; <span style=\"color: #228B22\">% max duration of the simulation (non-dimensional)<\/span>\r\ndt = 0.005; <span style=\"color: #228B22\">% time step<\/span>\r\n\r\n[SRZ, t] = zombies(Npop, alpha, beta, zeta, delta, tmax, dt, 0);\r\nplotPopulations(t, SRZ, Npop)\r\nsnapnow<\/pre>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainZombie\/mainZombie_01.png\"> <\/p>\n<p>Hmm, what if we work on our sharp shooter skills and eat healthy?<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">alpha = 1e-2; <span style=\"color: #228B22\">% Go to the range<\/span>\r\ndelta = 9e-5; <span style=\"color: #228B22\">% Add broccoli<\/span>\r\n[SRZ, t] = zombies(Npop, alpha, beta, zeta, delta, tmax, dt, 0);\r\nplotPopulations(t, SRZ, Npop)\r\nsnapnow<\/pre>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainZombie\/mainZombie_02.png\"> <\/p>\n<p>That only delays the inevitable; skip the broccoli, we need to execute a mass extermination of zombies.  The <tt>erad<\/tt> function gives us the ability to raid them.\n   <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">delta = 1.2e-4; <span style=\"color: #228B22\">% Back to pizza<\/span>\r\nk = 0.65;\r\nNraid = 4;\r\n[SRZ, t] = erad(Npop, alpha, beta, zeta, delta, k, Nraid, tmax, dt,0);\r\nplotPopulations(t, SRZ, Npop)<\/pre>\n<pre style=\"font-style:oblique\">Zombies have been eradicated (until now...). \r\n<\/pre>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainZombie\/mainZombie_03.png\"> <\/p>\n<p>Unfortunately, the model doesn&#8217;t seem to account for new humans being born, so I think any simulation eventually ends with us all dead&#8230;  Have a great weekend!\n   <\/p>\n<h3>Comments<a name=\"5\"><\/a><\/h3>\n<p>Give it a try and let us know what you think <a href=\"http:\/\/blogs.mathworks.com\/pick\/?p=10264#respond\">here<\/a> or leave a <a href=\"http:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/54368#comments\">comment<\/a> for E.\n   <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">\r\n<span style=\"color: #0000FF\">function<\/span> plotPopulations(t, SRZ, Npop)\r\nfigure\r\nplot(t, SRZ);\r\nylim([0, 1.1*Npop])\r\nlegend(<span style=\"color: #A020F0\">'Susceptibles'<\/span>, <span style=\"color: #A020F0\">'Deads'<\/span>, <span style=\"color: #A020F0\">'Zombies'<\/span>, <span style=\"color: #A020F0\">'location'<\/span>, <span style=\"color: #A020F0\">'west'<\/span>)\r\nylabel(<span style=\"color: #A020F0\">'Population'<\/span>)\r\nxlabel(<span style=\"color: #A020F0\">'Non-dimensional Time'<\/span>)\r\n<span style=\"color: #0000FF\">end<\/span>\r\n<\/pre>\n<p><script language=\"JavaScript\">\n<!--\n\n    function grabCode_30e9b5a031144744bfd76a395190329c() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='30e9b5a031144744bfd76a395190329c ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 30e9b5a031144744bfd76a395190329c';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        author = 'Sean de Wolski';\n        copyright = 'Copyright 2018 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('\n\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\n\n\\n');\n      \n      d.title = title + ' (MATLAB code)';\n      d.close();\n      }   \n      \n-->\n<\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><a href=\"javascript:grabCode_30e9b5a031144744bfd76a395190329c()\"><span style=\"font-size: x-small;        font-style: italic;\">Get<br \/>\n            the MATLAB code<br \/>\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>      Published with MATLAB&reg; R2018b<\/p>\n<\/div>\n<p><!--\n30e9b5a031144744bfd76a395190329c ##### SOURCE BEGIN #####\n%% Zombie Outbreak!\n%\n% <http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495 Sean>'s\n% pick this week is\n% <http:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/54368 Mathematical\n% modelling of an outbreak of zombie infection> by\n% <http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/4608373 E. Cheynet>.\n% \n\n%% \n%\n% In honor of Halloween, E. has provided us with a way to simulate zombie\n% outbreaks!  Do you have what it takes to save humanity?\n\nNpop = 500; % population\nalpha = 7.5e-3 ; %  \"zombie destruction\" rate.\nbeta = 5e-3; % \"zombie creation\" rate.\nzeta = 9.2e-2; % zombie resurrection rate\ndelta = 1.2e-4; % susceptibles death rate\ntmax = 100; % max duration of the simulation (non-dimensional)\ndt = 0.005; % time step\n\n[SRZ, t] = zombies(Npop, alpha, beta, zeta, delta, tmax, dt, 0);\nplotPopulations(t, SRZ, Npop)\nsnapnow\n\n%% \n% Hmm, what if we work on our sharp shooter skills and eat healthy?\n\nalpha = 1e-2; % Go to the range\ndelta = 9e-5; % Add broccoli\n[SRZ, t] = zombies(Npop, alpha, beta, zeta, delta, tmax, dt, 0);\nplotPopulations(t, SRZ, Npop)\nsnapnow\n\n%% \n% That only delays the inevitable; skip the broccoli, we need to execute a\n% mass extermination of zombies.  The |erad| function gives us the ability\n% to raid them.\n\ndelta = 1.2e-4; % Back to pizza\nk = 0.65;\nNraid = 4;\n[SRZ, t] = erad(Npop, alpha, beta, zeta, delta, k, Nraid, tmax, dt,0);\nplotPopulations(t, SRZ, Npop)\n\n%% \n% Unfortunately, the model doesn't seem to account for new humans being\n% born, so I think any simulation eventually ends with us all dead...  Have\n% a great weekend!\n\n%% Comments\n% \n% Give it a try and let us know what you think\n% <http:\/\/blogs.mathworks.com\/pick\/?p=10264#respond here> or leave a\n% <http:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/54368#comments\n% comment> for E.\n%\n% <include>plotPopulations.m<\/include>\n\n##### SOURCE END ##### 30e9b5a031144744bfd76a395190329c\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"http:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainZombie\/mainZombie_01.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>Sean&#8216;s pick this week is Mathematical modelling of an outbreak of zombie infection by E. Cheynet.<\/p>\n<p>In honor of Halloween, E. has provided us with a way to simulate zombie&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2018\/11\/02\/zombie-outbreak\/\">read more >><\/a><\/p>\n","protected":false},"author":87,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10264"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=10264"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10264\/revisions"}],"predecessor-version":[{"id":10274,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10264\/revisions\/10274"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=10264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=10264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=10264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}