Thursday, July 12, 2012

A morbid Python script

Comics #493 and #893 involve actuarial tables, which are tables for calculating the probability that someone of a given age will die within a given amount of time.

One evening, when I was feeling morbid, I wrote a Python script to calculate death probabilities for any collection of people: actuary.py (.txt). It takes a list of ages and genders and produces various statistics. Here’s the report for the nine living people who have walked on the moon:

~$ python actuary.py 81m 82m 80m 81m 80m 81m 76m 78m 77m  There is a 5% chance of someone dying within 0.08 years (by 2012).  There is a 50% chance of someone dying within 1.1 years (by 2013).  There is a 95% chance of someone dying within 4.08 years (by 2016).    There is a 5% chance of everyone dying within 10.78 years (by 2023).  There is a 50% chance of everyone dying within 16.12 years (by 2028).  There is a 95% chance of everyone dying within 22.57 years (by 2035).    Probability of all dying in 1.0 year: <0.001%  Probability of a death within 1.0 year: 46.32%

And here’s the table for four of the main stars of the original Star Wars (Harrison Ford, Carrie Fisher, Mark Hammill, James Earl Jones):

~$ python actuary.py 69m 55f 60m 81m 10  There is a 5%  chance of someone dying within 0.42 years (by 2012).  There is a 50% chance of someone dying within 4.74 years (by 2017).  There is a 95% chance of someone dying within 12.83 years (by 2025).    There is a 5%  chance of everyone dying within 18.17 years (by 2030).  There is a 50% chance of everyone dying within 31.28 years (by 2043).  There is a 95% chance of everyone dying within 42.62 years (by 2055).    Probability of all dying in 10.0 years:   0.272%  Probability of a death within 10.0 years: 85.94%

Of course, these are based on average death rates based only on age and gender. Adding more specific information about the people in question will refine the calculation. For example, I’d guess former astronauts are more likely to be in good health—and have longer life expectancies—than the rest of us.

No comments:

Post a Comment