Previous Entry: “Why I won’t update Orbit Classic for Firefox 4”
Next Entry: “The girl version of the “On the population dynamics of “Puella Magi Madoka Magica”” essay” 2011-10-16On the population dynamics of “Puella Magi Madoka Magica”This sketch is devoted to the population dynamics of the fictional world depicted by the Japanese animated TV series “Puella Magi Madoka Magica”. As such, it is inevitable going to reveal at least one major plot point. So if you are planning to watch this show, I suggest that you postpone reading this sketch until you are done watching it. You have been warned: there will be spoilers. Basic setting In the world of “Puella Magi Madoka Magica”, there are magical girls fighting against witches. Human girls can become magical girls (although it is debatable whether magical girls are still human, for the purpose of this sketch I will treat “humans” and “magical girls” as non-overlapping categories, to facilitate talking about the respective populations; I could call the non-magical-humans “muggles”, but that starts with the same letter as “magical girls”), they can kill witches and they can be killed by witches. Witches can spawn familiars, those familiars can also fight with magical girls, and they can mature into witches themselves. And magical girls become witches too (and Tyler Durden is just a figment of the narrator’s imagination, and Doctor Malcolm Crowe was dead all along, and Dumbledore dies, and Rosebud was his sled, and Rimmer complained about the soup being too cold while dining with the officers). The show is slightly ambiguous on how magical girls become witches: we will have to return to this point. On the other hand, it is clear how human girls become magical girls: they are tricked into a contract by aliens with ulterior motives. Anyway, we have four populations: the humans , the magical girls , the witches and the familiars , and their relations are as follows: I model these relations as an iteration with discrete time steps (I’ll leave the meaning of the smallest time unit unspecified, whether it means a day, a week, a month or a year won’t matter)(I could use a system of differential equations, but I prefer a model which can be run by a simple spreadsheet application, to make it easier for fellow otakus to check or alter my models (see also Appendix A)): A word on the notation: if “” and “” are two populations, then “” denotes a function of the number of members of the population turning into members of the population , with as the pseudo-population of the dead respectively unborn. This system is subject to some dramaturgical restraints: the production of familiars can result in an exponential growth of witches which could quickly wipe out humanity; but since the show tells us that witches existed since the dawn of time, this can’t happen quickly or with a high probability, that is, the population dynamics of our system should be mostly stable. On the other hand, for dramaturgical reasons, it is desirable that a magical girl, on average, has to fight several witches, has a real chance of dying in such an encounter, and has a high probability of becoming a witch herself (otherwise, being a magical girl would lack suspense, drama and angst). The question arises whether these constraints can be satisfied simultaneously. Especially, on the Puella Magi Wiki, population models have been proposed which are either highly unstable or lack drama. To tackle this question, I propose two simplifications of the basic model. First, since I’m searching a stable solution, I will treat humanity as an infinite pool where magical girls can be recruited. If the population of witches grows out of control, the number of humans will decline, and with all humans gone, it will be impossible to recruit new magical girls. But with stable (and comparatively small) populations of magical beings, this should be irrelevant. The second simplification is less obvious: I’ll get rid of the population of familiars. From the standpoint of magical girls, witches and familiars are different: fighting them costs magical energy which can be replenished using “grief seeds”, but only witches have grief seeds. A magical girl exclusively fighting familiars will loose her magical energy and turn into a witch. Therefore, the ratio of witches to familiars might matter for the rate of magical girls turning into witches. There are two reasons I’ll ignore familiars nevertheless: first, I expect the ratio of witches to familiars to be more or less constant. And second, I’ll model the transition of magical girls into witches as largely independent of witches anyway (see below). So instead of witches spawning familiars and the familiars maturing into witches, I simply have witches spawning more witches. Accordingly, my model reduces to this: A simple mostly linear model for the equilibrium case The model above has 5 functions we need to specify. For four of these functions, I will propose simple linear relations. How do witches spawn familiars, and how do familiars mature into witches? The show doesn’t explain this in detail, so several possibilities spring to mind. It might be that the familiars need to spend some time being undisturbed, so the presence of many magical girls could slow down the production and maturing of familiars. Or perhaps a familiar killing a magical girl gets a boost and matures quicker or a witch needs to kill a magical girl to produce a familiar. Although I can’t rule out these possibilities, I’ll ignore them for a simpler model: the number of witches produced via familiars is simply proportional (with some constant factor ) to the number of witches present: How do magical girls become witches? They can loose all their magic energy fighting witches and familiars. The series shows (in episode 10) an instance of this happening: Madoka defeats Walpurgisnacht, but in the process looses so much energy that she instantly turns into a witch herself. But I think that this is an exceptional case. I assume that usually, a magical girl can avoid this situation by collecting grief seeds or avoiding fights with familiars if her magical energy runs low. Instead, I assume that the main factor turning magical girls into witches is them becoming overwhelmed by grief and loosing their will to continue fighting. Therefore, I model the transition of magical girls as being proportional to the number of magical girls: How often do magical girls and witches meet each other and engage in a fight? Different assumptions are possible: it could be that a magical girls searches exactly one witch during one iteration, and, provided that there are enough witches present, always finds one. But I assume that a magical girl engages in more fights if there are more witches present. The number of fights should be proportional to . In each fight, either the magical girl or the witch dies. Not accounting for experience or maturation, I assume that the probability of a magical girl surviving an encounter with a witch is a fixed number. I also assume that fights between magical girls and witches are the only way of them dying, and none of them dies of old age or other non-magical causes. The number of magical girls dying is therefore And correspondingly the number of witches dying is The last remaining function we need to model is , the number of human girls the aliens recruit during one iteration step. This function is slightly different than the other four, since we can assume that the aliens choose this number deliberately to achieve certain goals. What would these goals be? I assume they want to achieve a stable equilibrium with the number of witches equal to some desired target number . If they have settled for some , this restrains the possibilities for the size of the population . Since we have and we also know that for a stable equilibrium, , we have And knowing both and , we can at last compute for the equilibrium case: For illustrative purposes, I’ll provide a model scenario with explicit numerical values: I assume that the aliens want to settle for an equilibrium with 2,000 witches, so Furthermore, I assume that during each iteration step, a magical girl has a 4 % chance of becoming a witch, and a 20 % chance of meeting a witch. During a fight, she has a 10 % chance of dying. With these numbers, a magical girl lives long enough to experience some angst and drama and suffering, and she will most likely end up as a witch in the end: ending up as a witch is twice as likely as ending up being killed. To achieve this, I set . I also set and . Now setting would constrain , but I want to specify instead as 1,000 (I want to investigate the case where the magical girls keep the number of witches in check without drowning them, so I want twice as many witches than magical girls). This, in turn, restrains the possible values of to For the setting I have chosen, this means a value of . Now we have this situation: there are 2,000 witches and 1,000 magical girls. In each iteration step, 40 girls become witches, and 20 girls are getting killed. Accordingly, the aliens recruit 60 new girls. Furthermore, 180 witches are killed, and 140 new witches are produced via familiars. A magical girl, on average, lives for almost 17 iterations, while a witch lives for slightly more than 11 iterations. On average, a magical girl kills one and a half witch. This average kill rate is rather low. It depends on how much witches come into being starting as magical girls, and how many started as familiars. The more witches start as familiars, the more witches a magical girl will kill on average before dying or becoming a witch herself, but the less likely it becomes for her to loose a fight. An important difference between different model scenarios is whether or dominates witch production. If the latter dominates, most witches stem from familiars, and we need either lots of magical girls, or magical girls almost never loosing a fight to keep them at bay, both settings bound to reduce drama and angst. On the other hand, if the former term dominates, a magical girl can’t fight many witches. Assume a scenario with . Then the average magical girl can, if the populations are in equilibrium, kill at most one witch, since magical girls are the only source of witches in this scenario, and one magical girl becomes only one witch herself. The more likely it is for a magical girl to die in a fight with a witch, the less likely it becomes that she will ever meet a witch in a fight at all. We can partially lessen this problem if we assume that the number of witches a magical girl kills is distributed rather unevenly. Then we would have lots of inexperienced girls killing few or none witches at all, and a few experienced girls regularly engaged in fights with witches. Nevertheless, at this point it seems doubtful whether it is possible to have a stable equilibrium with drama and angst and lots of fights. For example: is the equilibrium I just described stable? The success of rather dumb aliens To answer this question, we need to know the behavior of our model outside the equilibrium case. So far, we have defined the function only for the point . But what should the aliens do in situations outside the desired equilibrium? I think the most simplest and brain-dead answer to this question would be: simply just do the same. I re-name the value as a constant and define the function for really dumb aliens as The complete model then looks like this: For a specific scenario, I keep the values for the other constants as above, that is and set Now what happens if we set and ? It turns out that the population of the witches grows out of bounds: after 2,610 iteration steps, the witch population exceeds 2 million, while the population of magical girls collapsed. If we start with too few witches, that is, and , the system settles for a new equilibrium: We can also start with an initial population of one magical girl and zero witches. Although our aliens behave in a really dumb manner, the system settles for an equilibrium, although not the desired equilibrium: It turns out that our system has two equilibrium points. It is easy to see why: let be a fixpoint of this model. For a fixed point, we have Using these equations, we can use the second equation to express in terms of , as we already did above. Substituting this value in the first equation, we get This is a second-degree polynomial with two solutions for (and therefore two solutions for ). One of these solutions is our desired target , the other is not. If we keep with the values of the model scenario above, the target solution is 2,000 witches and 1,000 magical girl, but it turns out that there is another fixpoint with 1,714.2857… witches and 1,050 magical girls. Furthermore, the target fixpoint is a repelling fixpoint, while the second fixpoint is attractive (the spectral radius of the Jacobian matrix is 1.00243… for the first fixpoint, a value greater than 1, but 0.99747… for the second fixpoint, see Appendix B). Slightly less braindead aliens The aliens are in no way obliged to behave in such a blind-sighted way as depicted by the model above. Instead, they can adopt the number of girls they recruit according to the current population situation. A simple model would work like this: the aliens desire a witch population of witches. At time , there are present. We apply this deviation of the desired situation to the population of magical girls and get a new, temporary target for the population of magical girls: Now the aliens attempt to choose in such a way to assure that . We first define an idealized version of , namely, , which describes what the aliens would do if they could act without constraints: For the actual function , there are some constraints. If we assume that the aliens never outright kill magical girls themselves, then can never be negative. Furthermore, it seems natural to assume that the resources of the aliens are limited, such that there is a maximal number of magical girls they can recruit within each iteration step. At least, since the human population is finite, and so is the number of pubescent girls, the pool from which the aliens can recruit magical girls is limited. I therefore assume that there is an upper limit for the number of possible recruits during one iteration step. The actual function then becomes It should be noted that this model still has rather simple-minded and mechanical aliens. Nevertheless, it is surprisingly successful. For a concrete example, I pick the same parameters as above, with the only difference being the new definition of the function . For the remaining unspecified parameter , I choose a value of 100 (in the equilibrium case, the aliens recruit 60 girls during each iteration step; recruiting 40 girls more during a time of crisis seems feasible). Compare the two models: Since in this scenario the magical girls are rather efficient witch killers and the production of familiars is slow, a population of 1,000 magical girls and 9,115 witches still moves back to the desired equilibrium: Adding random noise So far, both models have been strictly deterministic. It is to be expected that there are random variations in the number of magical girls and witches, and a feasible alien strategy should be able to cope with such random deviations from a strictly deterministic model. A realistic model would be to add some normal distributed Gaussian noise to each function. But I decided against such a model, since, as mentioned above, I wanted to be able to compute models with simple spreadsheet functions to make it easier for others to compare and enhance my results. Instead, I have chosen a rather simplistic method of adding some noise. Let be a population how it would had developed from the state at time according to one of the two the deterministic models developed above, and let be a random distribution uniform on the interval from 0 to 1 (as usually produced by software random number generators), and let be a parameter to describe the severeness of the random noise. Then the model population in the disturbed model is defined as Let’s look again at our two models from above with extremely dumb and slightly less dumb aliens. For (which means that for each iteration step, both populations can randomly go up or down about 5 %), one possible outcome looks like this: To make matters worse for the model with dumb aliens, it takes on average about 1,200 iteration steps until the model becomes unstable and the witch population grows out of bounds. The “smart” aliens fare considerably better, their model stays stable for long amounts of time. Even if we reduce to the rather strict value of 70 (note that 60 new girls are needed in the equilibrium case), the model usually, in most runs, survives several thousand iteration steps without the witch population exploding. The following run shows how such a run almost gets out of bounds around iteration step 9,000: The movement of the point through phase space looks like this: For comparison, with we get a movement through phase space like this: On the other hand, with as high as 100, the model usually survives even random noise of magnitude for a substantial amount of time. The eventual breakdown might even be considered to be consistent with the TV series: after all, the system of magical girls and witches is supposed to be in place since prehistoric times, but nevertheless in most timelines doesn’t survive the appearance of the witch Walpurgisnacht. A possible criticism against the proposed scenario could be that magical girls fight against too few witches. We can rectify this by increasing the numbers of witches produced by familiars and also increasing the numbers of witches killed in a fight: we can set , keep , slightly adjust (there being half as much magical girls means that each of them has to fight more often), setting , which means that each girl survives 19 out of 20 fights, and can raise to . This means that in each iteration step, there are 400 fights, 380 witches are killed and 340 new witches are produced via familiars. Furthermore, each magical girl, on average, kills more than 6 witches, although she still has a 2/3 chance of turning into a witch herself. With her life expectation unchanged, this new scenario means that her life will be full of fighting (even more so if we assume a heavily skewed distribution between lots of girls killed early in their careers and a few experienced veterans). Even with and , this doesn’t pose a problem for the model in most runs, and witchplosions rarely ever occur (I failed to observe one within 200,000 iteration steps). Likewise, if we want to drag out the misery of the average magical girl, we can set , , and , while retaining . In this scenario, a magical girl kills 13 witches, still has a 2/3 chance of ending as a witch herself, and in each fight has a 2,5 % chance of being killed, so individual fights are still somewhat dangerous. Still, even with , this doesn’t pose a problem for the ability of the model to keep the witch population in check. If, on the other hand, we want to make life miserable for the magical girls and accept that they die like flies, we can also set the probability for each iteration step that they become a witch to 10 % and likewise set the probability that they get killed by a witch to 10 %. Furthermore, a fight with a witch should be really dangerous, with a magical girl loosing every third fight. We can achieve this by the following setting: Once again, this scenario is mostly stable: Conclusion There are restraints which prevent certain scenarios. It is impossible that almost all witches are the result of magical girls becoming witches and that simultaneously witches produce huge numbers of familiars which mature into witches, or that almost all magical girls end up as witches while being a magical girls means fighting lots of witches and that fighting a witch is very dangerous, all of this while at the same time this systems remains stable over long periods of times and was in place since the dawn of time (like the TV series implies). But if we are willing to sacrifice or relax at least some of these restraints, feasible models are possible. It is possible to have stable systems with significant random perturbations, it is possible to have more witches than magical girls, it is possible for magical girls to fight many witches on average, it is possible for many girls to end as witches, or it is possible for fights with witches to be dangerous. Whatever world we want to create, and whatever flavor of angst and drama we prefer, it is possible to construct scenarios which come close to these worlds, even with a rather simple model that doesn’t account for a more sophisticated behavior on the side of the aliens. Appendix A: Excel spreadsheet As promised above, you can download an Excel spreadsheet to fiddle with the different parameters of the two proposed models for yourself. The spreadsheet contains two tables. The table labeled “DumbFixpoint” is only relevant if you choose the model with dumb aliens. In this case, this table computes the two fixpoints. Furthermore, this table also computes the Jacobian matrix for these fixpoints, the corresponding two eigenvalues and the spectral radius. A spectral radius greater than 1 means that the fixpoint is repelling, the greater the value, the faster points in the neighborhood of the fixpoint are driven away. A spectral radius smaller than 1 means that the fixpoint is attractive, the smaller the value, the faster points in the neighborhood of the fixpoints are converging towards the fixpoints. For the mathematical details, see also Appendix B. The table labeled “Main” contains everything else. Parameters you can set are shown in light green. I wired the calculation in such a way that you don’t set the model constants directly, but some (hopefully more meaningful) precursors. If you set “Random Noise” to 0, you get a deterministic model. You can choose between the model with dumb and less dumb aliens by setting “SmartAliens” to “False” or “True”. When you change a value, the spreadsheet immediately starts to calculate the new model for 10,000 iterations. If your model has random noise and you want to start a new model run with different random values, simply change an empty cell. It may happen that the parameters you have chosen lead to an unbounded growth of the witch population, leading to population numbers exceeding the maximum numerical value Excel (or OpenOffice) can handle (in older versions of OpenOffice, you can actually crash the application this way). To prevent this, the model stops when a population grows larger than a large threshold value, and restarts again with the initial population values. The value “MeltdownCount” tells you how often this has happened, which is a measure of how unstable your model is. For example, if there is just one meltdown within the full 10,000 iterations, your model is almost stable, and only rare and unfortunate combinations of random noise make it become unstable. On the other hand, if you encounter several hundred meltdowns, your model seems to be rather hopeless. If you encounter no meltdown at all, this field is displayed with a green background, otherwise, it is red. There are also two diagrams with the populations of the magical girls and the witches, one for all 10,000 iteration steps and one just for the first 1,000 iteration steps. Another two diagrams show the movement of the model in the phase space: the x-axis is the number of magical girls, and the y-axis is the number of witches. In a typical growth-towards-an-attractive-fixpoint scenario with random noise, the model will start in the lower left corner, move towards the fixpoint and then start to randomly wander in the vicinity of this fixpoint. Once again, the upper diagram shows all 10,000 iteration steps, while the lower diagram is limited to the first 1,000 iteration steps. Appendix B: Fixpoints in a two-dimensional phase space The following section describes a well-known piece of math, which might nevertheless be of some interest for someone trying to reconstruct one the models I developed above. Before we consider the two-dimensional case, let’s start with one dimension: we have a function and a point with , and we want to know whether this fixpoint is attractive. A fixpoint is attractive if, for every sufficiently small, applying repeatedly to results in values coming closer and closer to . Therefore, we want to know if is absolutely smaller than , in which case the distance to would be shrinking. This is the case if But for small , the term on the left side of this equation is almost the same as the derivation . So in the one-dimensional case, a fixpoint of a function is an attractive fixpoint if With this result in mind, we turn to the two-dimensional case. Suppose we have two functions and , which both take two values. Furthermore, we have a point with and . How do we compute the derivation of such a function pair? There are four different ways: we have two partial functions, and we can compute the derivation for two different variables. The Jacobi matrix combines these four results: We are, of course, interested in the fate of our point , so we have to compute How do we know whether such a derivation matrix is large or small, whether it stretches or shrinks things, whether an iteration pushes neighboring points far away or attracts them? Such a matrix can be characterized calculating the eigenvectors of the matrix, vectors which keep their direction under the application of the matrix. Although the direction of an eigenvector remains unchanged under the application of the matrix, its length might change about a factor called an eigenvalue of the matrix. The eigenvalues describe how much such a matrix shrinks or stretches different directions. In the general case, computing eigenvalues of a matrix is difficult, but in the case of a 2×2 matrix, it is simple enough. For a matrix of the form the eigenvalues are If the absolute values of both eigenvalues are smaller than 1, then a point is drawn nearer. If one eigenvalue is greater 1, a neighboring point is driven away in at least one direction, and the fixpoint is not attractive. We can express this using the spectral radius , which is defined as A fixpoint is attractive if the spectral radius is smaller than 1. In the dumb model above, we have the following functions: Accordingly, we have these partial derivates: | QuicksearchRecent Entries
ArchivesLatest Skizzenblog EntryTags |
I'm impressed, to say the least! Going to share it with my fellow fans and see what they have to say as well
http://walpurgischan.net/meduka/res/3360.html