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.

371 thoughts on “A morbid Python script

  1. I LOVE Morbid Python! Those guys are so funny! Morbid Python’s Flying Saucer is one of my favorite shows. Oh man, you write scripts for that show? Cool!

  2. The fact that astronauts have passed through the radiation zones/areas with little protection from Earth’s magnetosphere practically guarantee them having cataracts within their lifespan. For all we know, they might not be expected to live longer than the average human being due to factors like that outweighing their time at peak physical fitness.

  3. Looking at most of the comments on this page I’m half expecting a Viking choir… Also, captcha is telling me it’s andtAgar time.

  4. Kako ono rece sinoc u “spektru” Ante Nobilo:Zalosno je sta HDZ Bosne i Hercegovine uopce nije promjenio politiku i namjere u svezi odcjepljenja…….Pretpostavljam da taj dragan covic radi za UDBU,jer do 1991. se je pisao jugoslavenom i potpisivao cirilicom.Hocu reci nije vjerovati ovim sta stalno isticu svoje hrvatstvo,jer mi to jako smrdi na spijune,kukavice,provokatore i placenike stranih obavjestajnih sluzbi.Hm,mozda grijesim,ali uvijek su tu sa svojim komentarima i udaraju u iste bubnjeve….hm

  5. tebi izgleda jos nije jasno da clanovi hdz-a popunjavaju, mozemo slobodno reci polovicu stranke, partije, kako hoces.. jugoslaveni, ostatak su hrvati i nesto ostalih mish-mash. slicno igranje brojki desava se u sdp-u, s time da su hrvati silom prilika prebaceni u mish-mash lonac dok su srbi ostatak! zdravo sumnjicavi

  6. Situated just opposite Elias Mall and within close proximity to Downtown East, White Sands Shopping Centre, IKEA Tampines, Courts Megastore and Giant, future residents a vibrant variety of retail and dining options within walking distance from their home

  7. Keppel Bay is a true Ocean Front living, the very best in urban and waterfront lifestyles. Just five minutes’ drive away from the Central Business District, yet nestled in one of Singapore’s best-loved nature and recreation enclaves.

  8. Become A Total Badass At Meeting And Attracting Women. This site is a leading resource for information about the Joshua Pellicer Tao Of Badass PDF book and attraction system that helps average, everyday men find and attract amazing women. Includes a collection of PDF reviews, download

  9. Competition has also knocked the doors of Internet market. There is no such website which is not under the impact of this competition. So, in this situation every website owner needs to adopt some different and unique strategies.

  10. On the other hand, it is also true that search engine algorithms are never constant. They keep on updating themselves to keep everything genuine and original. To make your website SEO friendly, one needs to hire a professional or SEO expert.

  11. When it comes to SEO London service, one can say that the professionals there offer white hat SEO services at affordable price range. These services are offered to improve the visibility of any website running on the internet.

  12. Once the visibility is improved, you will get more traffic and customers which ultimately leads to high sales. Now-a-days even Software Developer UK are optimizing SEO techniques in development of the sites. So, hire an expert carefully and get benefited.

  13. Belgravia Villas is located in a central location where there are plenty of amenities in the vicinity within a short driving distance to Ang Mo Kio Hub, NEX, Compass Point, Orchard and Bugis area. Dining, shopping and recreation options for you and your loved ones are just a stone’s throw away

  14. Your code sure was a nightmare of style errors, but I finally brought it in line with the PEP8 Python style guide. Just in case you didn’t know: always surround = == > < with spaces, there's no need for brackets in while statements, and no line may be more than 79 characters long. http://www38.zippyshare.com/v/23165197/file.html

  15. I’m trying deploy a Python application on Windows as a folder that includes a full python 2.6 folder. I don’t need/want a fancy solution like py2exe, I’m just trying to automate deployment of a web application.

  16. I know this web site offers quality dependent articles
    or reviews and other material, is there any other website which provides such information in quality?

  17. Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.
    Hi, I am 14 year old and quit high school to get to Bronze IV. I left house to play league of legends everyday but i crie evrytiem. Plz surry for my englando. Plz no capi pasterino.

  18. Could you add a license with your python script (and a date and a statement of authorship)? It would clarify a bit what you mean. Or put it in the public domain if that’s really what you mean.

    If you mean to share code, putting it on github would be excellent.

  19. Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C. The language provides constructs intended to enable clear programs on both a small and large scale.

  20. How much would these percentages change if you also calculated the chance that there is a serial killer that hates star wars?

  21. Python runs on Windows, Linux/Unix, Mac OS X, and has been ported to the Java and .NET virtual machines.
    Python is free to use, even for commercial products, because of its OSI-approved open source license.
    New to Python or choosing between Python 2 and Python 3? Read Python 2 or Python 3.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>