The numbers a country runs on
How many people live in each district? How fast are prices rising? How many people are out of work, how many babies were born last year, how much did the economy grow? The answers decide how parliamentary seats are drawn, how money is shared between regions, how pensions and wages are adjusted for inflation, where schools and clinics are built, and how central banks set interest rates. They are produced by national statistical offices: the Office for National Statistics in the United Kingdom, Statistics Canada, IBGE in Brazil, INEGI in Mexico, Statistics South Africa, the Kenya National Bureau of Statistics, India's National Statistics Office, the Statistics Bureau of Japan, the US Census Bureau, Eurostat for the European Union, and some two hundred others.
Such numbers are useful only if people trust them, and trust rests on two promises. The first is integrity: the figures are compiled by professionals according to published methods, free from political interference, and released to everyone at the same time. The second is confidentiality: what you tell the statistical office about yourself is used only for statistics, never to identify or act against you. The United Nations' Fundamental Principles of Official Statistics, adopted by the UN Statistical Commission in 1994 and endorsed by the General Assembly in 2014, put both in writing; countries have their own codes, such as the UK Statistics Authority's Code of Practice. Where integrity has been broken, the damage has been long-lasting: in the late 2000s and early 2010s, official inflation figures in Argentina and public-deficit statistics in Greece both came under international criticism, and both countries spent years rebuilding confidence in their statistical systems.
This lesson is about the tension between the two promises. The more detailed the statistics an office publishes, the more useful they are — and the more they may reveal about the individuals behind them. Modern computing has made that tension sharper, and the statistical response, differential privacy, is one of the most consequential ideas to come out of computer science and statistics in the last twenty years.
Censuses: counting everyone
A census attempts to count every person (and often every dwelling) in a country at one moment, recording a few characteristics of each. Rulers have counted their subjects for taxation and armies since antiquity; regular modern censuses, published for public use, date from the late eighteenth and nineteenth centuries — the United States from 1790, England and Wales and Scotland from 1801 — and most countries now take one about every ten years, following UN recommendations for each "census round".
Censuses are taken in two main ways. Traditional enumeration sends forms (now often online) to every household, with field staff following up those who do not respond. Register-based censuses assemble the count from administrative registers of population, dwellings, employment and education; the Nordic countries, the Netherlands, Austria and Slovenia, among others, produce census statistics largely or entirely this way, and several other countries are moving in that direction. Registers are cheaper and more frequent, but only as good as their coverage and the legal and ethical framework that governs linking them.
No census is perfect. Some people are missed and some counted twice, and the misses are not random: young children, people with no fixed address, remote communities and some minority groups are typically undercounted. Statistical offices measure this with a post-enumeration survey — an independent, careful re-count of a random sample of areas, matched person by person against the census — and with demographic analysis of birth, death and migration records. This is the capture–recapture logic that ecologists use to estimate animal populations, applied to a whole nation with the sampling care of Samples and surveys, and its results are published: the US Census Bureau's post-enumeration survey for 2020, for example, found statistically significant over- or undercounts in a number of states.
A census is also the sampling frame for most other surveys and the denominator of most rates — births per thousand, cases per hundred thousand. Its small-area detail, down to blocks of a few dozen people, is what makes it irreplaceable. That same detail is what makes it hard to protect.
Disclosure risk and reidentification
Statistical disclosure happens when published statistics let someone learn something about an identifiable person or business. The obvious risk is a small cell: a table showing one person aged 90–94 in a village tells everyone who knows that person their other recorded characteristics. Less obvious risks come from combining tables, or from subtracting one published figure from another.
For decades statistical offices have managed these risks with statistical disclosure control: suppressing small cells, coarsening categories (age groups instead of exact ages), top-coding extreme values, rounding, and perturbing the data before tabulation. Record swapping exchanges the geographic location of a few similar households between areas; the cell-key method, developed at the Australian Bureau of Statistics, adds small, consistent pseudo-random perturbations to each published count. The ONS, for example, used targeted record swapping and cell-key perturbation for the 2021 census of England and Wales. These methods work well against casual disclosure, and their details are deliberately kept confidential.
Three lines of research showed that "anonymised" data are often much less anonymous than they look:
- Linkage. Latanya Sweeney estimated in 2000 that about 87% of the US population could be uniquely identified by five-digit postcode, date of birth and sex alone — attributes that appear in many "de-identified" datasets and in public records. Rocher, Hendrickx and de Montjoye (2019) estimated that 15 demographic attributes would identify 99.98% of Americans in any dataset. Narayanan and Shmatikov showed that a few movie ratings with approximate dates could pick out an individual's record in a large "anonymised" ratings dataset.
- Reconstruction. Irit Dinur and Kobbi Nissim proved in 2003 that if a database answers too many statistical queries too accurately, someone can reconstruct almost all of its individual records. Every published table is a set of answered queries, so a census publishing billions of exact counts is, in principle, exposed.
- The 2010 US census experiment. The Census Bureau tested this on its own 2010 publications, which had been protected by swapping. Its researchers reported (Abowd et al., 2023) that they could reconstruct 97 million person records exactly — every resident of 70% of census blocks — on block, sex, age, race and ethnicity, and that an attacker could correctly reidentify about 3.4 million of the most vulnerable people, with 95% accuracy. Critics, notably Ruggles and Van Riper, argued that the Bureau never compared its results with chance: assigning ages and sexes at random within a block, and the block's most common race and ethnicity, would match an actual person about 41% of the time, close to the Bureau's reported 46% exact-match rate. The debate is about how much the reconstruction adds beyond what anyone could guess, and how to count harm — and it shaped how the 2020 census was published.
Differential privacy
Traditional disclosure control asks "could someone identify a person in this table?" and must guess what an attacker knows. Differential privacy, introduced by Cynthia Dwork, Frank McSherry, Kobbi Nissim and Adam Smith in 2006, changes the question to one that can be answered without guessing: does the output depend much on any one person's data?
Definition— Differential privacy
Two datasets are neighbours if they differ in the data of one person (one record added or removed). A randomised algorithm is -differentially private if for every pair of neighbouring datasets and every set of possible outputs,
The number is the privacy-loss parameter: smaller is more private. The relaxation -differential privacy adds a small to the right-hand side.
The definition has a useful interpretation. Whatever an observer believed beforehand about whether you are in the data, or what you answered, seeing the output can change their odds by at most a factor . With that factor is 2.72; with it is 1.11. And the guarantee holds whatever else the observer knows — even if they know everyone else's records exactly — which is precisely the situation in which exact statistics fail.
Definition— Sensitivity
The () sensitivity of a function from datasets to is over neighbouring : the most one person can change it. A count has sensitivity 1. A histogram in which each person falls in exactly one cell also has sensitivity 1, however many cells it has.
Theorem— The Laplace mechanism
Releasing , with independent Laplace random variables of scale (density ), is -differentially private.
Proof
Fix neighbours and an output . The ratio of the output densities is
using the triangle inequality . Integrating the inequality between densities over any set gives the definition.
∎
Three properties make differential privacy a practical tool, not just a definition:
- Post-processing. Anything computed from a differentially private output, without going back to the data, is just as private. Rounding, removing negative counts and fitting a model to noisy tables cost no privacy.
- Sequential composition. Releasing several outputs computed from the same people, with budgets , is -private. The privacy loss adds up, so an organisation must keep a privacy budget.
- Parallel composition. Outputs computed on disjoint sets of people cost only the largest of their budgets. A table of counts for separate blocks, or separate age groups, can give each cell the full budget.
import numpy as np
from scipy import stats
rng = np.random.default_rng(1)
def laplace_mechanism(true_value, sensitivity, epsilon):
"""Release true_value plus Laplace noise with scale sensitivity / epsilon."""
return true_value + rng.laplace(0.0, sensitivity / epsilon, np.shape(true_value))
# Two neighbouring datasets, identical except for one person, so a count differs by 1.
count_D, count_D2, epsilon = 120, 121, 1.0
release = lambda c: stats.laplace(loc=c, scale=1 / epsilon) # the distribution of what is published
print(f"epsilon = {epsilon}: no event may become more than e^epsilon = {np.exp(epsilon):.3f} times more likely")
print(f"{'published value lies in':24s} {'P (count 120)':>14} {'P (count 121)':>14} {'ratio':>7}")
for lo, hi in [(-np.inf, 118), (118, 120), (120, 121), (121, 123), (123, np.inf), (126, np.inf)]:
p = release(count_D).cdf(hi) - release(count_D).cdf(lo)
q = release(count_D2).cdf(hi) - release(count_D2).cdf(lo)
print(f"{f'({lo:g}, {hi:g}]':24s} {p:14.4f} {q:14.4f} {q / p:7.3f}")
# Why it matters: the "differencing" problem. Two exact counts, with and without one
# person, reveal that person's answer; two noisy counts reveal almost nothing.
print(f"\nexact counts with and without one person: {count_D2} and {count_D} -> difference {count_D2 - count_D}")
a, b = laplace_mechanism(count_D2, 1, epsilon), laplace_mechanism(count_D, 1, epsilon)
print(f"noisy counts: {a:.1f} and {b:.1f} -> difference {a - b:.1f}")
noise_sd = np.sqrt(2) * (1 / epsilon)
print(f"standard deviation of one released count: {noise_sd:.2f} (for a count of 120, about {100 * noise_sd / 120:.1f}%)")The table checks the definition directly: for every event, the probability under one dataset is at most times that under the other, and for every value above 121 the ratio is exactly that bound. The noise needed is small in absolute terms — a standard deviation of 1.41 people on a count of 120 — yet the differencing comparison at the end, which would expose one person exactly, now tells you almost nothing.
The privacy–accuracy trade-off
Differential privacy makes a trade-off explicit that older methods left hidden: more privacy (smaller ) means more noise. The noise is of a fixed absolute size — about people per count — whatever the size of the population, so its relative effect depends dramatically on how many people a statistic is about.
import numpy as np
rng = np.random.default_rng(2)
# Synthetic areas of very different sizes; in each, 12% of residents have some characteristic.
areas = {"hamlet": 40, "village": 400, "town": 4_000, "city": 400_000}
share = 0.12
print("typical error of a published count, as a percentage of the count (mean absolute error)")
print(f"{'epsilon':>8} {'error (people)':>15}" + "".join(f"{f'{name} ({pop:,})':>17}" for name, pop in areas.items()))
for eps in [0.1, 0.5, 1.0, 2.0, 8.0]:
abs_err = np.mean(np.abs(rng.laplace(0, 1 / eps, 20000))) # the same for every area: 1/epsilon on average
row = [100 * abs_err / round(share * pop) for pop in areas.values()]
print(f"{eps:8.1f} {abs_err:15.2f}" + "".join(f"{e:16.3g}%" for e in row))
# Composition: the same total budget spread over many published tables.
total_eps, pop = 1.0, 4_000
print(f"\na town of {pop}, total epsilon {total_eps}, split equally over k tables that each count every resident")
for k in [1, 10, 100]:
noisy = rng.laplace(0, k / total_eps, 20000) # each table gets epsilon / k
print(f" k = {k:3d}: mean absolute error per count {np.mean(np.abs(noisy)):7.1f} people")
# Post-processing is free for privacy, but not for bias: rounding and clipping at zero.
true_count = 1
raw = true_count + rng.laplace(0, 1 / 0.5, 200000)
clipped = np.maximum(np.round(raw), 0)
print(f"\ntrue count {true_count}, epsilon 0.5: mean of raw releases {raw.mean():.3f}, "
f"after rounding and clipping at 0 {clipped.mean():.3f}")The last line shows a subtler effect. Rounding to whole numbers and replacing negative values by zero are free in privacy terms, but not in accuracy: for a true count of 1 at , the published value is 1.60 on average instead of 1. Clipping removes the negative errors and keeps the positive ones, so small counts are biased upwards. Statistical offices therefore often publish the raw noisy measurements as well, so that analysts can make unbiased estimates themselves.
The next simulation runs the whole pipeline on a synthetic county of 300 census blocks: noisy counts by age group, post-processing to whole, non-negative numbers with the county total held exact, and synthetic person records generated from the result.
import numpy as np
rng = np.random.default_rng(2020)
# A synthetic county: 300 census blocks of very different sizes, residents in three age groups.
n_blocks = 300
pop = np.maximum(1, np.round(rng.lognormal(np.log(60), 1.2, n_blocks))).astype(int)
shares = rng.dirichlet([3, 10, 2], n_blocks) # 0-17, 18-64, 65+ in each block
truth = np.array([rng.multinomial(p, s) for p, s in zip(pop, shares)]) # true table: blocks x age groups
print(f"{n_blocks} blocks, {truth.sum():,} residents; block sizes from {pop.min()} to {pop.max():,} (median {int(np.median(pop))})")
# Each person is in exactly one cell, so noise of scale 1/epsilon on every cell protects the whole table.
epsilon = 0.5
noisy = truth + rng.laplace(0, 1 / epsilon, truth.shape)
# Post-processing (costs no privacy): whole, non-negative counts ...
published = np.maximum(np.round(noisy), 0)
# ... and an exact county total (an "invariant"), restored by scaling and largest-remainder rounding.
target = truth.sum()
scaled = published * target / published.sum()
floor = np.floor(scaled)
extra = int(target - floor.sum())
order = np.argsort(-(scaled - floor), axis=None)[:extra]
floor.flat[order] += 1
published = floor
print(f"county total: true {target:,}, published {int(published.sum()):,} (held exact)")
size_class = np.digitize(pop, [25, 100, 400])
names = ["under 25", "25-99", "100-399", "400 or more"]
print(f"\n{'block size':12s} {'blocks':>6} {'mean error in block total':>26} {'mean abs error, share 65+':>27}")
for c, name in enumerate(names):
m = size_class == c
total_err = (published[m].sum(axis=1) - truth[m].sum(axis=1)) / truth[m].sum(axis=1)
pub_share = published[m, 2] / np.maximum(published[m].sum(axis=1), 1)
true_share = truth[m, 2] / truth[m].sum(axis=1)
print(f"{name:12s} {m.sum():6d} {100 * total_err.mean():+25.1f}% {100 * np.mean(np.abs(pub_share - true_share)):26.1f} pts")
# Synthetic microdata: one record per published person. Anything computed from them is still epsilon-DP.
records = np.repeat(np.arange(published.size), published.astype(int).ravel())
block_of, age_of = np.divmod(records, 3)
print(f"\nsynthetic microdata: {records.size:,} records; share aged 65+ "
f"{np.mean(age_of == 2):.4f} (true {truth[:, 2].sum() / truth.sum():.4f})")Because every resident is in exactly one block-by-age cell, noise of scale on every cell protects the whole table at a cost of (parallel composition). The pattern of errors is the important result. Blocks with fewer than 25 residents are inflated by 8.9% on average, and their published share of people aged 65 or over is off by 13.4 percentage points; blocks of 400 or more are accurate to within half a percent, and slightly deflated. The cause is post-processing: clipping inflates small counts, and holding the county total exact then takes the excess from everyone else in proportion to size. The synthetic microdata reproduce the county's overall share aged 65 or over almost exactly (0.1329 against 0.1308), because large aggregates are barely affected.
Differential privacy in the 2020 US census
The US Census Bureau was the first national statistical office to protect a full population census with differential privacy. The facts, as the Bureau and independent researchers have published them:
- Why. After its internal reconstruction experiments on 2010 data, the Bureau concluded that the record swapping used in 2000 and 2010 could no longer meet its legal duty of confidentiality, and announced well before the count that 2020 would use formal privacy instead. It had used a differentially private method earlier, for the commuting-flow maps of its OnTheMap service, from 2008.
- How. The TopDown Algorithm (Abowd et al., 2022) takes noisy measurements of many tables at each level of the geographic hierarchy — nation, state, county, tract, block group, block — using a discrete Gaussian mechanism under a variant of differential privacy called zero-concentrated differential privacy. Post-processing by large-scale optimisation then produces whole, non-negative and mutually consistent tables at every level.
- Invariants. Some figures were published exactly, outside the privacy guarantee: the total population of each state (used to apportion seats in the House of Representatives), the number of housing units in each block, and the number of group-quarters facilities, such as prisons and university residences, by type in each block.
- Budget. In June 2021 the Bureau set the production budget for the redistricting data at in its concentrated-privacy measure (2.56 for persons, 0.07 for housing units), stated as the equivalent of in total, 17.14 of it for the person data. This was considerably higher — less private, more accurate — than in the demonstration data released earlier, after data users reported problems with accuracy.
- Debate. Demographers, redistricting experts and representatives of American Indian and Alaska Native communities raised concerns about accuracy for small areas and small populations; analyses of demonstration data found that post-processing, rather than the noise itself, introduced systematic distortions, such as sparsely populated areas tending to gain population and denser ones to lose it (Kenny et al. studied the effect on redistricting). The state of Alabama sued to stop the method; in June 2021 a federal court declined to block it. Supporters argued that a formal, published guarantee was the only defensible response to reconstruction; critics, that the threat was overstated and the cost to data users too high.
- Since. Later 2020 census products used the same framework. As of 2025 the Bureau has opened a public research programme on disclosure avoidance for the 2030 census, so the methods for the next census remain under study.
Elsewhere, technology companies have used local differential privacy — noise added on each user's device before data are collected — for telemetry since about 2014, and differentially private methods have been used for some releases of administrative and mobility data. Most national statistical offices still rely mainly on traditional disclosure control, sometimes strengthened with formal privacy for particular products. Open-source tools such as OpenDP and Google's differential privacy libraries have made the methods far easier to apply correctly than they were in 2010.
Synthetic data
An alternative to publishing tables is to publish synthetic microdata: artificial records drawn from a statistical model fitted to the confidential data, so that analysts can work with individual-level files that contain no real person. Donald Rubin and Roderick Little proposed the idea in 1993, building on multiple imputation; the US Census Bureau has released synthetic versions of some survey and business data, with a validation server through which an analyst's final results can be checked against the confidential data.
Two cautions apply.
- Synthetic is not automatically private. A flexible generative model can memorise and reproduce unusual records, and attackers can sometimes tell whether a person's record was in the training data (membership inference). Synthetic data come with a formal guarantee only when the model is fitted with differential privacy — for example by fitting it to noisy marginal tables, as in McKenna, Miklau and Sheldon's winning entry in a competition run by the US National Institute of Standards and Technology. The synthetic records in the county example are of this kind: they are post-processing of a differentially private table.
- Synthetic data preserve only what the model captures. If the model preserves age by block but not age by occupation, an analysis of age and occupation on the synthetic file will find whatever the model assumed, not what is in the population. Synthetic data are excellent for teaching, testing code and exploring; conclusions should be confirmed on the real data, through a validation server or a secure research environment.
The same reasoning applies to the "synthetic data" now widely used to train machine-learning models: generating records from a model does not by itself remove the privacy risk of the data the model was fitted to.
Common misconceptions
Misconception
"Removing names and ID numbers makes data anonymous." A few ordinary attributes — postcode, date of birth, sex — identify most people uniquely, and linking with other sources does the rest. Anonymity is a property of the whole release and of what else is public, not of a deleted column.
Misconception
"Differential privacy means the data are encrypted, or that nobody can learn anything." The confidential data are used in the clear by the statistical office; what is limited is what the published output reveals about any one person. And aggregate facts are meant to be learned — that is the point of statistics. If a study reveals that smoking causes cancer, a smoker's risk is revealed whether or not they took part; differential privacy promises only that their participation made almost no difference.
Misconception
"Adding a little noise to each figure is enough." Without a sensitivity analysis and a budget across all releases, noise can be averaged away: publish the same count a thousand times with independent noise and the mean is nearly exact. Composition is the accounting that prevents this.
Misconception
"Noise makes small-area statistics useless." It makes them noisier, and for very small areas the relative error can be large. But aggregates of small areas — the population of a county, a city ward or a school catchment built from many blocks — remain accurate, because independent noise partly cancels when counts are added.
A note on truthfulness
Optional Christian reflection · Just weights and honest numbers
A reflection from the Christian tradition that inspires Lumenary Academy. It is not part of the mathematics and you are welcome to skip it.
An old proverb says, "A false balance is abomination to the LORD: but a just weight is his delight" (Proverbs 11:1). In the ancient marketplace the scale was the public number everyone relied on and nobody could check for themselves; a merchant who shaved the weights stole a little from everyone. Official statistics are the scales of a modern society. Keeping them just means publishing the figures that are true rather than the figures that are welcome, saying plainly how uncertain they are, and keeping faith with the people who answered — each of whom is a person, not a row, and was promised that their answers would never be turned against them. Differential privacy is, among other things, a way of keeping a promise exactly.
Exercises
1. Privacy and official statistics
Warm-upHumanA statistical office releases the number of people in a district who cycle to work, with the Laplace mechanism at . Adding or removing one person changes the count by at most 1. What is the scale of the Laplace noise?
2. Privacy and official statistics
CoreHumanAn office publishes 8 different tables about the same residents of a town (age by sex, household size, commuting, and so on). Each table is produced with a mechanism that is -differentially private. By sequential composition, what is the total privacy-loss parameter for the whole release?
3. Privacy and official statistics
CoreHumanA country publishes the population of each of its 50 provinces, each count released with Laplace noise at . Every person lives in exactly one province. What is the privacy guarantee of the release of all 50 counts together?
4. Privacy and official statistics
CoreHumanAn office has released a differentially private table of noisy counts. Which of the following further steps spend additional privacy budget? Select all that apply.
5. Privacy and official statistics
CoreComputationalWrite private_histogram(counts, epsilon, rng) that returns a differentially private version of a histogram (any NumPy array of counts, in which each person contributes to exactly one cell). Add independent Laplace noise of scale 1 / epsilon to every cell, drawing it from the generator rng (a numpy.random.Generator, e.g. rng.laplace(...)), and return an array of the same shape. Do no rounding or clipping.
6. Privacy and official statistics
StretchComputationalWrite private_mean(values, lo, hi, epsilon, rng) returning an -differentially private estimate of the mean of values, where the number of values is public and two datasets are neighbours if one person's value is changed. First clip every value to the interval [lo, hi] (so one person can move the sum by at most hi - lo), then add Laplace noise of scale to the mean of the clipped values. Draw the noise from rng.
7. Privacy and official statistics
Warm-upHumanA release is -differentially private with . Which statement is correct?
Further reading and resources
- Fundamental Principles of Official Statistics · United Nations Statistics DivisionThe ten principles adopted by the UN Statistical Commission and endorsed by the General Assembly.
- Code of Practice for Statistics · UK Statistics AuthorityOne country's code for trustworthiness, quality and value in official statistics.
- The Algorithmic Foundations of Differential Privacy · Cynthia Dwork and Aaron Roth · 2014The standard monograph, free from the author's site.
- Calibrating Noise to Sensitivity in Private Data Analysis · Cynthia Dwork, Frank McSherry, Kobbi Nissim and Adam Smith · 2006The paper that defined differential privacy and the Laplace mechanism (Theory of Cryptography Conference).
- Revealing Information while Preserving Privacy · Irit Dinur and Kobbi Nissim · 2003The database reconstruction result (Symposium on Principles of Database Systems).
- Simple Demographics Often Identify People Uniquely · Latanya Sweeney · 2000Carnegie Mellon University, Data Privacy Working Paper 3.
- How To Break Anonymity of the Netflix Prize Dataset · Arvind Narayanan and Vitaly Shmatikov · 2006Published in 2008 as "Robust De-anonymization of Large Sparse Datasets".
- Estimating the success of re-identifications in incomplete datasets using generative models · Luc Rocher, Julien Hendrickx and Yves-Alexandre de Montjoye · 2019
- A Simulated Reconstruction and Reidentification Attack on the 2010 U.S. Census · John Abowd and others · 2023
- The Role of Chance in the Census Bureau Database Reconstruction Experiment · Steven Ruggles and David Van Riper · 2021A critique arguing that much of the reconstruction's match rate could be achieved by chance.
- The 2020 Census Disclosure Avoidance System TopDown Algorithm · John Abowd and others · 2022
- Census Bureau Sets Key Parameters to Protect Privacy in 2020 Census Results · United States Census Bureau · 2021The production privacy-loss budget for the redistricting data.
- Disclosure avoidance (2020 and 2030 censuses) · United States Census Bureau
- The Impact of the U.S. Census Disclosure Avoidance System on Redistricting and Voting Rights Analysis · Christopher Kenny and others · 2021
- Winning the NIST Contest: A scalable and general approach to differentially private synthetic data · Ryan McKenna, Gerome Miklau and Daniel Sheldon · 2021
- OpenDPAn open-source community project building tools for differential privacy.
- Google's differential privacy librariesOpen-source libraries for differentially private aggregation.