{"id":113,"date":"2020-01-10T15:13:43","date_gmt":"2020-01-10T21:13:43","guid":{"rendered":"https:\/\/pages.stolaf.edu\/freedberg\/?page_id=113"},"modified":"2020-01-10T15:50:19","modified_gmt":"2020-01-10T21:50:19","slug":"simulating-biology","status":"publish","type":"page","link":"https:\/\/pages.stolaf.edu\/freedberg\/simulating-biology\/","title":{"rendered":"Simulating Biology"},"content":{"rendered":"<p>We write computer programs to simulate biological populations, allowing us to predict how real life organisms will act under specific circumstances. If you haven&#8217;t done it, writing coding might seem daunting, but it&#8217;s really just giving directions to a computer in a way it will understand. I&#8217;ll even show you how you can write code to simulate a real biological situation.<\/p>\n<p>Let&#8217;s start with an asexual (all-female) population we&#8217;ll call $pop:<\/p>\n<blockquote><p>$pop=1000<\/p><\/blockquote>\n<p>Now we want to simulate reproduction. To give each female a chance to reproduce, we&#8217;ll create a loop that starts with the 1st female ($x=0), then keeps counting ($x++) until it goes through the whole population ($x&lt;$pop):<\/p>\n<blockquote><p>for($x=0; $x&lt;$pop; $x++)<\/p><\/blockquote>\n<p>Now we&#8217;ll give each female a 50% chance of reproducing. rand(1) will randomly choose a number between 0 and 1. If the number is greater than 0.5, the female will add an offspring to the next generation ($pop2); if it&#8217;s less than 0.5, it won&#8217;t:<\/p>\n<blockquote><p>if(rand(1)&gt;0.5){++$pop2}<\/p><\/blockquote>\n<p>That&#8217;s it! Our whole program looks like this:<\/p>\n<blockquote><p>$pop=1000;<\/p>\n<p>for($x=0; $x&lt;$pop; $x++){<\/p>\n<p>if(rand(1)&gt;0.5){++$pop2}<\/p>\n<p>}<\/p>\n<p>print $pop2<\/p><\/blockquote>\n<p>When I ran it, I got 516 offspring in the next generation. That will change slightly each time we run it. Cool. Now what could we do to give each mother a 50% chance of having a 2nd offspring? (feel free to email me with the answer if you want to try this).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We write computer programs to simulate biological populations, allowing us to predict how real life organisms will act under specific circumstances. If you haven&#8217;t done it, writing coding might seem daunting, but it&#8217;s really just giving directions to a computer &hellip; <a href=\"https:\/\/pages.stolaf.edu\/freedberg\/simulating-biology\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3577,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-113","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/pages.stolaf.edu\/freedberg\/wp-json\/wp\/v2\/pages\/113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pages.stolaf.edu\/freedberg\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/pages.stolaf.edu\/freedberg\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/pages.stolaf.edu\/freedberg\/wp-json\/wp\/v2\/users\/3577"}],"replies":[{"embeddable":true,"href":"https:\/\/pages.stolaf.edu\/freedberg\/wp-json\/wp\/v2\/comments?post=113"}],"version-history":[{"count":5,"href":"https:\/\/pages.stolaf.edu\/freedberg\/wp-json\/wp\/v2\/pages\/113\/revisions"}],"predecessor-version":[{"id":124,"href":"https:\/\/pages.stolaf.edu\/freedberg\/wp-json\/wp\/v2\/pages\/113\/revisions\/124"}],"wp:attachment":[{"href":"https:\/\/pages.stolaf.edu\/freedberg\/wp-json\/wp\/v2\/media?parent=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}