- Summarise the overall performance of the class (including the performance on the individual coursework);
- Summarise the performance of the class on the group coursework

**Note that at this point in time the marks are provisional and could be scaled
by the Exam board.** I do not expect this to happen as the marks distributions
are within a reasonable range of the University guidelines (TLDR: they are slightly
higher than the norm).

A summary of the overall class performance is given here:

The University guidelines

The group coursework is a difficult assessment marked on a difficult scale. Summary of the class marks are here:

```
count 82
mean 66.54
std 10.08
min 37
25% 59.65
50% 67.20
75% 71.80
max 88
```

The average is a bit above the University guidelines which are that the mean class mark should be within \(62 \pm \frac{80}{\sqrt{n}}\) where \(n\) is 82 in this class (the number of students in the class).

I was incredibly impressed with the work you accomplished this Semester. Some projects where really innovative and well executed.

A summary of the class marks are here:

```
count 82
mean 53.78
std 10.56
min 35.00
25% 47.00
50% 50.00
75% 55.00
max 80
```

This is similar to the marks from last year where the median was 53.

Thank you again for your work this year. If you would like to discuss your marks and/or get further feedback please do get in touch.

]]>You can find a recording of the class here: https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=c2ba2206-7bd5-40a0-9e77-b15900b5e4dd

]]>You can find a recording of the class here: https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=2ce53e1e-4109-412a-bab2-b15500a55d8b

You can find the first draft of the paper
here. If helpful, the `tex`

file is [here](You can find the first draft of the paper
here

We discussed the paper at length and you can find some of our discussion captured in the board I used here.

Some of the main points discussed were:

- Consistency of spelling and/or grammar.
- Some areas where mathematics makes the text less clear and some areas where mathematics helps with clarity.
- Moving some aspects from the introduction to presentation where more depth could be given.
- Consider the color of the graphics to ensure inclusive reading.
- Add some details about the graphics to ensure they’re clear.
- Adding more depth to the description of the graphics.

After this, we put together a story board for the presentation. You can see that on the board here.

]]>You can find a recording of the class here: https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=d95cc0bd-30b6-4912-be8c-b15200c67221

You can find the notebook I used here.

After this, as a class we discussed what pieces of the work would be better suited to the paper or the presentation.

You can find a copy of the board I used here.

The main conclusion was:

**The paper should contain**:

- Description of the game.
- Theory: to include background of replicator dynamics and the fitness function used for the two thirds of the average game model.
- Relevant other work (if any).
- The results.

**The presentation should contain**:

- Description of the game.
- Motivation (to include the historical play of the game).
- Some discussion of the limitations of the model.
- Validation and demonstration of the code.
- The results.

Here is a summary:

```
Mark
count 94.000000
mean 85.042553
std 17.249538
min 8.000000
25% 78.000000
50% 92.000000
75% 97.000000
max 100.000000
```

You can see the distribution of marks here:

Here is a summary of the performances in each specific area that I checked:

- Q1a correct type: 89.90 %
- Q1a correct answer: 89.90 %
- Q1b correct type: 90.91 %
- Q1b correct answer: 90.91 %
- Q1c correct type: 92.93 %
- Q1c correct answer: 85.86 %
- Q1d correct type: 92.93 %
- Q1d correct answer: 92.93 %
- Q2a correct value: 88.89 %
- Q2b correct answer: 93.94 %
- Q2c correct type of variable: 90.91 %
- Q2c 0 contained in variable: 68.69 %
- Q2c correct answer: 60.61 %
- Q3a correct values: 90.91 %
- Q3a check probabilities sum to one: 94.95 %
- Q3a values correspond to correct types: 90.91 %
- Q3b correct length of probabilities: 88.89 %
- Q3b variable is a list: 88.89 %
- Q3b correct value: 69.70 %
- Q4a correct size of game: 90.91 %
- Q4a correct value of game: 89.90 %
- Q4b variable is generator: 45.45 %
- Q4b correct value of distributions and play counts: 96.97 %

**I welcome all discussions about your individual coursework, if you would like
to me to discuss your coursework please do get in touch.**

You can find a recording of the class here: https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=e1002ad9-e7f9-4dd6-ade5-b15000950bfc

We finished the class by discussing my notes on principles for presentation: https://vknight.org/pop/.

]]>You can see a recording of this here: https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=9f82fa36-ff3c-476b-898f-b11e00c66c6c

You can see a picture of the board I used here.

The Moran process is a game theoretic model of evolution. One of the differences
from the Replicator Dynamics equation is that the population is assumed to be
**finite**: so we assumed there is a finite population of \(N\) individuals
that can be of any of the types that correspond to actions of the underlying
Norma Form Game.

In the example of the Hawk Dove game that we played in class we assumed there
were \(N=3\) individuals and the question we attempted to understand was: *if
we introduce a Hawk in to a population of Doves, what will happen?*

The Moran process then follows the following:

- Calculate the fitness of all individuals: everyone in the population plays the Normal Form game against everyone else. Their utility (or fitness) is given by their type and the type of the individual they play with.
- Randomly select an individual for copying proportional to their fitness.
- Randomly select an individual for removal (all individuals are equally likely to be removed).
- Create a new individual of the same type as the one selected in step 2.
- Remove the individual selected in step 3.

Repeat that process until there is a single type of individual in the population.

In class we used dice to simulate the above. We were a bit short on time at the end so not everyone got to complete a simulation. We did still find a probability of 50% of the Hawk taking over.

Here is a notebook with some numeric simulations of the probabilities. If you look through the notes you can see approaches for calculating exact fixation probabilities.

]]>You can see a recording of this here: https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=5cc70927-0793-4dd5-9690-b11a00c682d0.

After this we discussed potential reasons for the emergence of the social convention of walking on a particular site of the road (on the left in the UK for example).

We used the following game to model this using Replicator Dynamics:

\[A = \begin{pmatrix} 1 & -1 \\ -1 & 1\\ \end{pmatrix}\]This game is meant to model the interaction of individuals in a given population who interact (by walking past each other). If both these individuals walk according to the same convention then they get a utility of 1 but if not they get a utility of -1.

We then model a given population using a vector \(x=(x_1, x_2)\) where \(x_1\)
corresponds to the **proportion** of individuals walking according to the
first convention (say: the left) and \(x_2=1-x_1\) is the **proportion**
walking
according to the second convention.

We can then compute the average utility of an individual who walks using the
first convention (we can refer to this as the **first type** and to utility as
**fitness**). They will interact with another individual of the first type
\(x_1\) of the time getting a fitness of \(1\) and an individual of the
second type \(x_2\) of the time getting a fitness of \(-1\). The average
utility is then:

The average utility of the individuals of the second type are:

\[f_2 = - x_1 + x_2\]The average utility over the entire population is then given by:

\[\phi=x_1f_1+x_2f_2\]In the notes on Replicator Dynamics you can find linear algebraic expressions of these quantities \(f\) and \(\phi\) that extend naturally to populations with more than just 2 types.

The **actual** Replicator Dynamics equation is then given by:

In the case of our game this corresponds to:

\[\begin{align} \frac{dx_1}{dt} =& x_1 (x_1 - x_2 - x_1(x_1 - x_2)+x_2(x_2 - x_1))\\ \frac{dx_2}{dt} =& x_2 (-x_1 + x_2 - x_1(x_1 - x_2)+x_2(x_2 - x_1)) \end{align}\]which can be simplified to:

\[\begin{align} \frac{dx_1}{dt} =& x_1 ((x_1 - x_2) - (x_1 - x_2) ^2)\\ \frac{dx_2}{dt} =& x_2 ((x_2 - x_1) - (x_1 - x_2) ^2) \end{align}\]Substituting \(x_2=1-x_1\) we have:

\[\begin{align} \frac{dx_1}{dt} =& x_1 (2x_1 - 1)2(1-x_1))\\ \frac{dx_2}{dt} =& -x_1 (2x_1 - 1)2(1-x_1)) \end{align}\]And we see (setting the derivatives to be equal to 0) that there are 3 stable populations:

- \(x_1=0\): Everyone drives on the right.
- \(x_1=1\): Everyone drives on the left.
- \(x_1=1/2\): Half the population drives on the left and half on the right.

The fact that this is **stable** mathematically (ie the derivatives are zero)
corresponds to the game theoretic fact that in these populations every type of
individual has the same fitness: **so no one behaviour has an evolutionary
advantage.**

You can see a recording of this here: https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=f55bd298-4d8a-4973-9361-b11700c6837f.

Thanks to you all for participating and making this good fun.

After the tournament (congratulations to **Mathletico Madrid**) we briefly
talked about Axelrod’s tournaments which have spurned a large amount of research
on the emergence of cooperation.

You can see a recording of this here: https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=a1b89a57-d6f1-4092-a958-b11300c68136.

In class I asked you to write down strategies for a play of the centipede game.

This required writing down an action to take at *every* possible node of the
centipede game.

You can see a pdf with the scans of every strategy here. (Forgive the token effort of removing your names, if anyone would like me to take this down please let me know).

There were essentially 3 strategies played:

- Take at the first opportunity – Let write this as: TT.
- Pass at the first opportunity but take at the second – Let us write this as PT
- Pass always – Let us call this: PP

If we consider just these 3 actions then we can reformulate the game as a two player game with the action sets: $A_1=A_2={\text{TT}, \text{PT}, \text{PP}}$.

Using this we can now rewrite the utility functions for both players by reading from the tree definition of the centipede game:

\[A = \begin{pmatrix} 2 & 2 & 2\\ 1 & 4 & 4\\ 1 & 3 & 4\\ \end{pmatrix} B = \begin{pmatrix} 0 & 0 & 0\\ 3 & 2 & 2\\ 3 & 5 & 4\\ \end{pmatrix}\]The Nash equilibria for this can then be computed:

```
>>> import numpy as np
>>> import nashpy as nash
>>> A = np.array(
... (
... (2, 2, 2),
... (1, 4, 4),
... (1, 3, 4),
... )
... )
>>> B = np.array(
... (
... (0, 0, 0),
... (3, 2, 2),
... (3, 5, 4),
... )
... )
>>> game = nash.Game(A, B)
>>> list(game.vertex_enumeration()
[(array([1., 0., 0.]), array([1., 0., 0.]))]
```

This corresponds to both players picking to take at the first opportunity. If both players do this: neither have a reason to change what they are doing.

This was not the exact game I wrote down at the end of the class where we also included the strategy to take at the first node and hypothetically pass at the second. Of course no one wrote that one down as it does not make immediate sense. If I were to change how I play this game (perhaps I will do this next year) I would not only randomise who is player 1 or player 2 but also randomise the node at which to start playing.

You can find the notebook I used in class here

]]>