-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimNotes.txt
32 lines (30 loc) · 1.29 KB
/
SimNotes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Advance the current simulation state by one year
function advanceSimState(sim, country) {
// Calculate the number of children born this year
newborns = 0;
for (i=minFertilityAge; i<=maxFertilityAge; i++) {
newborns += sim.femalePop[i] * country.fertility[i];
// Remove the ones that died
newborns = newborns * country.infantFertilityRate;
// Advance the ages
// Got to treat the oldest bin specially
tempMale = sim.popMale[maxAge] * country.deathMale[maxAge];
tempFemale = sim.popFemale[maxAge] * country.deathFemale[maxAge];
for (i=maxAge; i>=1; i--) {
sim.popMale[i] = sim.popMale[i-1] * country.deathMale[i-1];
sim.popFemale[i] = sim.popFemale[i-1] * country.deathFemale[i-1];
}
// The oldest bin is actually maxAge+, so add back in the ones we saved
sim.popMale[maxAge] += tempMale;
sim.popFemale[maxAge] += tempFemale;
// Now put the newborns into bin 0
sim.popMale[0] = newborns * country.newMaleFrac;
sim.popFemale[0] = newborns * country.newFemalFrac;
}
* Need to calculate the TFR.
* Need to calculate the life expectancy.
* Need to verify that those calculation match expected values from other
data files.
* Need to check that the new births we generate in the first year of
the simulation generally match the number of 0-year-olds on initial
country data load.