private void btnBeta_Click(object sender, EventArgs e) { List <double> stbResults = new List <double>(); List <double> amrResults = new List <double>(); List <double> colcheroResults = new List <double>(); int coinCountStb = 0; int coinCountAmr = 0; int coinCountColch = 0; int coinFixedInf = 0; for (int i = 0; i < 10000; i++) { double betaStb = (1 - (MathFunctions.SampleBeta(VitalRates.INFSTB_A, VitalRates.INFSTB_B))); if (MathFunctions.CoinFlip(betaStb)) { coinCountStb++; } stbResults.Add(betaStb); double betaAmr = (1 - (MathFunctions.SampleBeta(VitalRates.INFAMR_A, VitalRates.INFAMR_B))); amrResults.Add(betaAmr); double fixedAmr = VitalRates.MonthlySurvival(0, true); if (MathFunctions.CoinFlip(fixedAmr)) { coinFixedInf++; } if (MathFunctions.CoinFlip(betaAmr)) { coinCountAmr++; } double colchero = VitalRates.MonthlySurvival(120, false); colcheroResults.Add(colchero); if (MathFunctions.CoinFlip(colchero)) { coinCountColch++; } } SaveResults("StbResults.txt", stbResults); SaveResults("AmrResults.txt", amrResults); SaveResults("ColchResults.txt", colcheroResults); MessageBox.Show("Files written, sample complete. Coin flip results: STB survived " + coinCountStb + " times, AMR " + coinCountAmr + " and 10 year old females survived " + coinCountColch + " times, fixed infant AMR survived " + coinFixedInf); }
//Test individuals for monthly survival using age-based survival rate and (if an infant), whether there is AMR risk public static bool IndSurvTest(int i, bool amr) { bool survived = MathFunctions.CoinFlip(VitalRates.MonthlySurvival(i, amr)); //if true, individual passed the survival test return(survived); }