.. Created by Adam Cunnningham on Fri Jun 3 2016. .. include:: isogrk3.rst .. |xt| replace:: x\ :sub:`t` .. |xt1| replace:: x\ :sub:`t+1` **The Mayfly Model** ==================== The “Mayfly Model” is a simplified model of how the mayfly population of a given year depends on the population of the previous year. In this model the population in year t is given by a scaled measure |xt| in the interval [0, 1]. The model assumes that in ideal conditions the number of surviving offspring per adult member of the population (including both males and females) is given by a variable b. As the population rises, increased competition for resources, and population reduction by predators and disease, act to reduce the number of surviving offspring. Taking this effect into account, the population of the following year, |xt1|, is modeled by the recurrence relation |xt1| = b |xt| (1 – |xt|). Report Description ------------------ The goal of this report is to explore the behavior of the Mayfly Model under a range of conditions. How does the system |xt1| = b |xt| (1 – |xt|) behave? Particularly: - How does it behave for different values of b? - Investigate both the transient and the asymptotic behavior. The report consists of the following exercises. **Exercise 1. Displaying the Transient Behavior** - Run the mayfly model using several different b values. - Plot the population each year over a long enough period of time for the system to have settled into a stable cycle. - Make some observations about your results. **Exercise 2. Displaying the Asymptotic Behavior** - Generate a high-resolution picture for a large number of b values. - Is this what you would expect? - Generate another picture zooming in on one area of the graph. - Do any kind of analysis you can to indicate what might be going on. **Exercise 3. Separation of Trajectories** Run the mayfly model with b = 1.5, b = 4, and some other values of your choice. - See if trajectories that start very close separate exponentially. - Use n\ :sub:`0` = m\ :sub:`0` + |epsiv| where |epsiv| = 10\ :sup:`-10`. - Graph the separation of nearby trajectories on a logarithmic scale against time using ``semilogy`` to plot log(s\ :sub:`t`) against t. **Exercise 4. Linear Least Squares** - Compute the growth rate of the separation during the time when it is growing exponentially. Use the "linear least squares" formula developed in class to compute the slope of the best-fit line on the logarithmic graph. The formula should be implemented from scratch in NumPy. - Graph both the separation of nearby trajectories and the "best fit" line to this separation on the same graph. Hints and Suggestions for the Report ------------------------------------ Initial Populations ~~~~~~~~~~~~~~~~~~~ We're interested in the rate at which two initial populations m and n that start close together either grow further apart or closer together. - The initial populations should be very close, say only 10\ :sup:`-5` apart. The simplest way to do this is to choose one initial population m, then let the other population be n = m + 10\ :sup:`-5`. - If things don't seem to be working with the initial population and separation you've chosen, try some others. - You may want to use a different initial population and separation for each b value. Experiment to find out what works best. Updating the Populations ~~~~~~~~~~~~~~~~~~~~~~~~ - The populations m and n are both updated each year for a given value of b. At time t, they will have values m(t) and n(t). - The mayfly model |xt1| = b |xt| (1 – |xt|) provides the formula to update the populations m and n each year. Calculating the Separation ~~~~~~~~~~~~~~~~~~~~~~~~~~ - The "separation" between m(t) and n(t) is defined as s(t) = abs(m(t) - n(t)). Plotting the Separation ~~~~~~~~~~~~~~~~~~~~~~~ - Over a limited time period, s(t) should follow the formula for exponential separation given by s(t) = s(0) e\ :sup:`rt`, where r is the rate at which the separation s(t) is growing. - The graph of log(s(t)) = \log(s(0)) + rt should therefore be a straight line over some limited time period. Linear Least Squares ~~~~~~~~~~~~~~~~~~~~ - When choosing data to apply the linear least squares formula to, make sure that the data *is* actually a straight line over this period. - When you use the linear least squares formula to find the coefficients |alpha| and |beta|, this needs to be done using y = log(s(t)) and x = t. This is because we are trying to fit a straight line to the *log* of the separation s(t), not directly to the separation s(t). - If |alpha| and |beta| are correct, then semilogy(t, \exp(|alpha| + |beta| t)) should show a straight line fit to the data over the time period you've chosen. Growth Rate ~~~~~~~~~~~ - Assuming that s(t) = s(0)e\ :sup:`rt`, then log(s(t)) = log(s(0)) + rt = |alpha| + |\beta| t. So, the growth rate r is just the value |beta| found using linear least squares, without needing any other computation.