← Lebenszeit

How Lifetime calculates its perspective

Plain-language explanation of the statistical method. The same content, condensed, is shown in the app under "How this is calculated".

The quantity

Lifetime shows remaining life expectancy at the person's current attained age, written e(x) in a life table: the average number of additional years lived by people in the reference population who have already reached exact age x.

It is not "life expectancy at birth minus your age". That shortcut ignores the fact that having reached age x, a person has already survived the mortality risks of every earlier age; e(x) + x is always larger than e(0) for x > 0.

The data

Publisher United Nations, Department of Economic and Social Affairs, Population Division
Dataset World Population Prospects 2024 — complete (single-year-of-age) life tables, estimates 1950–2023
Files WPP2024_Life_Table_Complete_Medium_{Both,Male,Female}_1950-2023.csv.gz (SHA-256 in data/VALIDATION_REPORT.md)
Column used ex — expectation of life at exact age x. Directly published; nothing is derived from mx/qx.
Reference period calendar year 2023, the latest estimate year in the release (2024 onward are projections and are not used)
Table type Period life table
Geography 237 countries/areas (LocTypeName == "Country/Area" with an ISO-3166 alpha-3 code). UN regional/income aggregates are excluded.
Population categories total = the UN's published both-sexes combined table; male; female. The combined table is never manufactured by averaging.
Ages 0–99 single years, plus the open-ended 100+ group
License Creative Commons Attribution 3.0 IGO (CC BY 3.0 IGO). Attribution: "© 2024 United Nations, DESA, Population Division. World Population Prospects 2024." Confirm on the WPP site before release (launch check).

Import and validation are reproducible: python3 data/import_wpp2024.py --download --raw data/raw --out App/Lifetime/Resources/LifeTables. The script filters, validates (complete ages, no duplicates, plausible e(0) and e(100+), all values positive, strictly decreasing e(x) from age 5, combined table within the male/female range), writes the compact JSON snapshot bundled with the app, writes reference_rows.json, and records checksums.

Reference rows were additionally cross-checked against the raw CSV with an independent awk pass (e.g. Austria, total, age 40: 42.8811; Nigeria, total, age 0: 54.4623 and age 1: 57.5101).

Age handling

What the number means — and does not

Unsupported cases

If the dataset fails validation, the country is not in the dataset, or a population table is missing for that country, the engine returns an explicit error and the app shows the non-numeric ("Focus on today") experience with a plain explanation. It never substitutes another country or fabricates a value.

Where the code lives

Updating the dataset

  1. When a new WPP release appears, update FILES, REFERENCE_YEAR, release and datasetID in data/import_wpp2024.py (rename it accordingly).
  2. Run the script with --download; it fails loudly on any validation problem.
  3. Copy the new reference_rows.json and snapshot into LifetimeCore/Tests/LifetimeCoreTests/Fixtures/ and run swift test.
  4. Re-read the license page and update attribution if the wording changed.