# We consider a system of individuals (the nature of which is irrelevant) that can take two states A and R: Mathematics and Computational Method, Assignment, UOS, UK

 University University of Southampton (UOS) Subject Mathematics and Computational Method
• Statement of problem

We consider a system of individuals (the nature of which is irrelevant) that can take two states A and R. At any point in time, an individual can only be in one state. There are no other states possible. We will denote by IA. the number of individuals in state .4 and by [1I] the number of individuals in state H. There are. V individuals in total. All individuals can be assumed to be in contact with all other individuals. At time t – 0, there are 13„ individuals in state 13. All other individuals are therefore in state A. Individuals in state .4 turn into state 13 at a rate of 34, i.e., proportional to the number of their neighbors that are in state 13. Individuals in state 13 turn into state A at a fixed rate;

Now, in an ideal world, you should be able to write the two ordinary differential equations (ODE) that describe this system. To make sure that everyone can proceed with the coursework, I am providing the ODEs on the last page of this document. Before consulting that section, you are strongly encouraged to try and come up with your own formulation.

• Analytical work

1. Using the fact that [A] + [B] = N at all times, write [B] as a function of [B], i.e., the expression should no longer involve [A]. This is your (so-called) mean-field equation.

2. Find the equilibria of the system and determine their stability. From now on, we will refer to the non-zero equilibrium as B*. You may find it useful to write your results in terms of the following quantity Ro = 1. Plot the phase portrait, i.e., [B] vs [A], identifying the equilibria and their stability (following convention described in the 2nd synchronous lecture of Unit 5

3. Produce the bifurcation plot for this system, that is, plot the value of the equilibria as a function of Ro, with Ro taking values from 0.1 to 5.0. For this question, the value of. V is irrelevant (provided it’s strictly positive) so use 1000 for example. This should be done using Python.

4. In this question, you are going to integrate [B] analytically to obtain an expression for [BJ(1), i.e., an expression that gives the number of individuals in state B in time. It is rarely the case that this can be done but with this system, it is possible. You will do this in four steps:

• Starting from the mean-field equation, factorize the right-hand side by [B]2, then write an expression for vt,[B]
• Consider the following variable substitution: y = *. Using the chain rule, express g) in terms of [B], then derive a simple expression for y, i.e., this expression should only involve y terms and parameters of the system. There shouldn’t be any [B] or [A]. However, it will be helpful to use 13• (calculated in the 2nd question) to simplify the expression
• Integrate this equation. You should be able to do this without any help, but if help is needed, you should note that this expression looks very much like the equation we solved during a synchronous lecture in Unit 4, replacing A and I by appropriate quantities. You can then use the result to derive an equation for y(t). Please see the short document summarising the derivation from the lecture.
• You can now produce a fully worked out expression for [B] (t) by remembering that [B] = Bo at time t = 0.

Using different values of Bo (between 1 and S — briefly discuss the case Bo = 0), plot solutions of [B](t) for various values of k between 0.1 and 5.0 (with = 0.5 for example). Confirm your expression for (t) is correct by (a) verifying that it converges to B’ for large times t and (b) visually confirming agreement when integrating the mean-field equation using Euler (use Python). What happens when Ro = 1? Speculate as to what this means. We will get back to this. For a given value of Bo, what happens when the value changes? Provide a brief explanation.

Do You Need Assignment of This Question

Simulation work

Some more could be done analytically but let’s now turn to simulations. For this part of the work, we will employ the Gillespie algorithm, an algorithm often used to simulate complex systems. There is something very important to understand here. The mean-field equation provided to you is derived from considering the interactions of a very large number of individuals.

The Gillespie algorithm, instead, provides discrete simulations of the system with few individuals by explicitly simulating every transition. In other words, a single run of the Gillespie algorithm represents one sample trajectory of all possible trajectories for this system. In principle, the average of a (sufficiently) large number of Gillespie runs should converge to the mean-field. This is what you will test here.

Gillespie provides a mathematically rigorous and computationally efficient alternative to agent-based modeling. You are not asked to compare the two approaches even if that would be an interesting thing to do (NB: but certainly not within this assessment!). To make sure everybody can work, I provide a Python implementation of the Gillespie algorithm for this problem. Use the code although feel free to write your own if you feel.

• Explore the behavior of the system when considering the suitably chosen scenarios, i.e., focus on the limit cases (e.g., small !?0, large Ro and /?4, = I; small N, large N; small 8,1, large BO. For each scenario, use the code provided to generate many realizations of the stochastic process. Plot all realisations on a single plot. Make relevant qualitative observations.
• For each scenario, calculate the average (and standard deviation) of the realizations. Here, you are going to face a problem linked with the nota bene from the introductory paragraph. You will need to think of a solution and implement it. Superimpose the average (and error bars) to the realisations. Use a larger line width for visibility.
• Finally, superimpose the mean-field solution. Again, use a larger line width and a different color for visibility. Describe and interpret agreement between the average of stochastic realizations and mean-field in relation to the choice of parameters. In this question, using Bo = 1 (i.e., only one individual in state 13 at t = 0) can help exacerbate the differences and help you think about what is happening. You may want to refer to your bifurcation plot.
• [Slightly challenging question]: Consider 100 replications for N = 1000„3 = 0.51, = 0.5 and 100 replications for N = 1000, 3 = 0.95, y = 0.5. You should notice a substantial difference in agreement between the mean-field and the average of the stochastic realizations depending on which scenario is considered. How could you improve the agreement for the scenario with the poorest agreement? Please note: The difference in 13′ is not the quantity of interest here. Rather you should think about why the agreement is so poor. This does not actually involve analytical work. An excellent answer would see you implement your proposed solution and provide evidence of improved agreement.

A bit of critical thinking

In this last part of the coursework, you are invited to think a bit more about what you have just done.

• So far the brief has provided no information whatsoever regarding what states A and B are and what the individuals are. Thinking about what is happening in this system, provide at least one example of a real-world scenario to which this model could apply. Bonus points will be given for any answer that provides two examples, one in which the equilibria are of interest and the other in which the critical regime (when AI = 1) is of interest. Either way, what is the benefit of being able to model the system?
• [Very tough question]: The model provided implicitly assumes that all individuals are potentially in contact with each other. What would be a more likely scenario? What changes would have to be made to the code of the Gillespie algorithm in order to include such a scenario? If you are able to do this, do it. Then, speculate as to what could affect the results observed in the previous questions. If you feel so inclined, demonstrate it experimentally. NB: Only 10 — marks have been given to this question. However, anyone managing it s, cessfully would receive an extra 10 marks for the assignment (with the mark capped to 100 obviously) 