bash: Last Day, The People Who Lived As Many Days as You

Definitions

  • bash: This is the command line, where you can run relatively simple scripted programs, available on all three major computing platforms.
  • SPARQL: On the Internet, there are repositories of information. Some of these repositories are in a format called RDF, or Resource Description Framework. Users of these repositories typically need a subset of the information contained in them. In order to get the desired information, they need a way to query these repositories in a structured way to get the information they want. SPARQL is that querying language.
  • Wikidata is an RDF repository. It is hosted by the same organization as Wikipedia, but it is subject to different rules. I do not think Notability and some of the cultural problems of Wikipedia extend to Wikidata. I’d be happy to hear if anyone is aware of problems in the dataset, since this is one of the few times I’ve worked with it.

Inspiration

Most mornings, my wife and I read The New York Times The Morning Briefing. Typically, this will include an obituary of a celebrity. If the person is less than 80 years old, my wife will say something like, “They died young.” She thinks everyone should live to be a hundred years of age.

I tend to think more relativistically. Someone died young, if they were younger than me. It got me thinking, “Is it possible to write a script to find out who lived exactly the same number of days I have lived today?”

It turns out to be fairly easy to do using bash, a SPARQL query link and Wikidata.

bash script

#!/bin/bash
# variables
BIRTHDAY=$(date -d '2000-01-01' +%s) # enter birthday in YYYY-MM-DD format
TODAYS_DATE=$(date +%s)
DAYS_ALIVE=$(((TODAYS_DATE - BIRTHDAY) / 86400)) # converts seconds to days

# Test output
# echo "birthday: ${BIRTHDAY} | today's date: ${TODAYS_DATE} | days_alive: ${DAYS_ALIVE}"

#url for sparql query of wikidata can be obtained: https://query.wikidata.org/, click link to it below
firefox 'https://query.wikidata.org/embed.html#SELECT%20DISTINCT%20%3Fperson%20%3FpersonLabel%20%3FpersonDescription%20WHERE%20%7B%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%22.%20%7D%0A%20%20%7B%0A%20%20%20%20SELECT%20DISTINCT%20%3Fperson%20%3FpersonLabel%20%3FpersonDescription%20%7B%0A%20%20%20%20%20%20%3Fperson%20wdt%3AP31%20wd%3AQ5%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20wdt%3AP569%20%3Fborn%3B%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20wdt%3AP570%20%3Fdied%3B%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20wdt%3AP27%20wd%3AQ30%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20BIND(%3Fdied%20-%20%3Fborn%20AS%20%3FageInDays).%20%0A%20%20%20%20%20%20FILTER(%3FageInDays%20%3D%20'"$DAYS_ALIVE"').%20%20%0A%20%20%20%20%7D%0A%20%20%20%20LIMIT%2025%0A%20%20%7D%0A%7D%0A'

bash script output

SPARQL query

You can input the following into the Wikidata SPARQL query interface and change the perimeters. Specifically, the bash variable $DAYS_ALIVE needs to be changed to an integer to work in the query interface, e.g., FILTER(?ageInDays = 11000). You can also do ranges using multiplication, e.g., FILTER(?ageInDays < (31*365) && ?ageInDays > (30*365)), if you want people between the ages of 30 to 31.

SELECT DISTINCT ?person ?personLabel ?personDescription WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?person ?personLabel ?personDescription {
      ?person wdt:P31 wd:Q5;             # any person
              wdt:P569 ?born;            # that has a birth date
              wdt:P570 ?died;            # and a death date
              wdt:P27 wd:Q30             # that was a citizen of the United States
      BIND(?died - ?born AS ?ageInDays). # calculate days they lived
      FILTER(?ageInDays = $DAYS_ALIVE).  # match the number of days to your current number of days alive
    }
    LIMIT 25
  }
}

Hang In There Until You’re Sixty

“…try to hang in there until you’re sixty. Then you’ll find you don’t have to worry about what people say any more and, as a consequence, life becomes a whole lot more interesting.

Entering your sixties brings with it a warm and fuzzy feeling of freedom through redundancy, through obsolescence, through living outside of the conversation and forever existing on the wrong end of the stick. What a relief it is to be that mad, embarrassing uncle in the corner of the room, a product of his age, with his loopy ideas about free speech and freedom of expression, with his love of beauty, of humour, chaos, provocation and outrage, of conversation and debate, his adoration of art without dogma, his impatience with the morally obvious, his belief in universal compassion, forgiveness and mercy, in nuance and the shadows, in neutrality and in humanity — ah, beautiful humanity — and in God too, who he thanks for letting him, in these dementing times, be old.”

—Nick Cave, “I’m struggling a bit with the fact I’m turning 40 in a week. Some people say “You’re in the brightest part of your life”, others say you are an “old man”. What is your perspective on getting old?RedHandFiles.com. June 2021.

Happiness Curve / U-Curve

For some reason, I believe I’ve posted the idea that happiness and perception of well-being follows a predictable curve that hits its low-point in one’s late 40’s for people in developed countries. However, looking for it right now, I was not able to find it. So, here’s a link to an overview article, a book length treatment, and a research article with the following abstract that brought the idea into popular currency:

“We present evidence that psychological well-being is U-shaped through life. A difficulty with research on this issue is that thereare likely to be omitted cohort effects (earlier generations may have been born in, say, particularly good or bad times). First, usingdata on 500,000 randomly sampled Americans and West Europeans, the paper designs a test that can control for cohort effects.Holding other factors constant, we show that a typical individual’s happiness reaches its minimumeon both sides of the Atlanticand for both males and femalesein middle age. Second, evidence is provided for the existence of a similar U-shape through thelife-course in East European, Latin American and Asian nations. Third, a U-shape in age is found in separate well-being regressionequations in 72 developed and developing nations. Fourth, using measures that are closer to psychiatric scores, we document a com-parable well-being curve across the life cycle in 2 other data sets (1) in GHQ-N6 mental health levels among a sample of 16,000Europeans, and (2) in reported depression-and-anxiety levels among 1 million UK citizens. Fifth, we discuss some apparent exceptions, particularly in developing nations, to the U-shape. Sixth, we note that American male birth-cohorts seem to have becomeprogressively less content with their lives. Our results are based on regression equations in which other influences, such as demo-graphic variables and income, are held constant.

-David G. Blanchflowera and Andrew J. Oswald, “Is well-being U-shaped over the life cycle?Social Science & Medicine. March 7, 2008.