🔒 Differential Privacy Health Dataset Sharing Simulator
This simulator demonstrates differential privacy techniques for sharing health datasets in research settings, ensuring that individual patient data remains private while still allowing useful statistical analysis.
Why Stripping Names Doesn't Anonymize Health Data
For decades, "de-identification" meant removing names, addresses, and Social Security numbers from a dataset and calling it safe to share. Differential privacy exists because this intuition is provably wrong: quasi-identifiers left behind — ZIP code, date of birth, sex, a rare diagnosis code — are almost always enough to re-link a "de-identified" record back to a named individual using nothing but public data.
- 87%: US population re-identifiable by ZIP+DOB+sex (Sweeney, 2000)
- 18: HIPAA Safe Harbor identifiers removed (still insufficient alone)
- 2: Netflix Prize users de-anonymized (from just 8 movie ratings + dates)
- 1: AOL search log users identified (named within days, 2006 leak)
The linkage attack: quasi-identifiers as fingerprints
In her landmark 2000 study, Carnegie Mellon computer scientist Latanya Sweeney showed that 87% of the US population could be uniquely identified using just three "harmless" fields: 5-digit ZIP code, full date of birth, and sex. She proved the point dramatically by re-identifying the medical record of Massachusetts Governor William Weld from a "de-identified" state employee health insurance dataset, cross-referencing it against a $20 voter registration list — and mailed him his own diagnoses.
This is the core failure mode DP is built to prevent: quasi-identifiers (attributes that are not names but that narrow down a population to a small, often unique, set of individuals) leak identity through combination, even when each field looks innocuous in isolation. Rare diagnoses compound the problem — a ZIP code with 40,000 residents can still uniquely identify the one person in it diagnosed with a rare genetic disorder in a given month.
HIPAA's Safe Harbor method (45 CFR §164.514) lists 18 identifiers to strip — names, geographic subdivisions smaller than a state, dates finer than year, and more — but explicitly does not guarantee anonymity; it is a compliance checklist, not a mathematical guarantee. HIPAA's alternative, Expert Determination, requires a statistician to certify re-identification risk is "very small," which is exactly the judgment call differential privacy replaces with a provable bound.
In 2006, Netflix released 100 million "anonymized" movie ratings for a $1M recommendation-algorithm prize. Researchers Arvind Narayanan and Vitaly Shmatikov (2008) showed that knowing just 8 approximate ratings and dates for a user — even with 14-day error — let them uniquely identify 99% of subjects in the dataset by cross-referencing public IMDb reviews, including revealing a closeted lesbian mother's film preferences in a resulting lawsuit.
Aggregation and k-anonymity are not enough either
Two intuitive "fixes" are commonly tried, and both can still leak:
• k-anonymity (Sweeney, 2002): generalize/suppress quasi-identifiers so every combination matches at least k records. But if all k records in a bucket share the same sensitive attribute (e.g., all diagnosed with HIV), an attacker learns the diagnosis with certainty even without picking out the individual — a "homogeneity attack."
• Simple aggregation (releasing only counts/sums): still leaks via differencing attacks. If a hospital publishes "patients with diagnosis X in ZIP 02138 this month: 4" and then, after one patient is discharged, "3" — the difference reveals that specific patient's diagnosis with certainty. Any two overlapping aggregate queries can be subtracted to isolate one record.
Differential privacy is the first framework with a mathematical proof that closes both holes simultaneously: it bounds what any attacker — with any amount of side information, including access to every other query ever answered — can learn about whether a specific individual is in the dataset at all.
Modern health-data re-identification incidents
The threat is not hypothetical or historical. Recent incidents show quasi-identifier and metadata leakage remains routine in health-adjacent products:
• 23andMe (October 2023): credential-stuffing attackers scraped genetic and ancestry profile data on roughly 6.9 million users via the "DNA Relatives" feature, exposing ethnicity estimates and family linkages that are inherently re-identifying because genetic data cannot be reset like a password.
• FTC actions against GoodRx (2023), BetterHelp (2023), and Flo Health (2021 settlement, finalized 2025 in parallel litigation): each was charged with sharing supposedly de-identified health app data — prescription intent, therapy status, menstrual/fertility data — with Facebook and Google ad platforms, which could re-associate it with named users via device and advertising identifiers.
These cases share a pattern: the data controller believed hashing an email or stripping a name was sufficient. Differential privacy reframes the question entirely — instead of asking "did we remove the obviously identifying fields," it asks "can the published output change measurably depending on whether any one specific person's record was included," and answers that question with a provable numerical bound, ε.
Global Sensitivity and the Privacy Budget ε
Differential privacy, formalized by Cynthia Dwork, Frank McSherry, Kobbi Nissim, and Adam Smith in "Calibrating Noise to Sensitivity in Private Data Analysis" (TCC 2006), gives a precise mathematical definition of privacy: a mechanism M is ε-differentially private if, for any two datasets D and D′ differing in exactly one record, and any output S, Pr[M(D)∈S] ≤ e^ε · Pr[M(D′)∈S]. The smaller ε is, the more the two probability distributions must overlap — the less any single patient's data can move the output.
- 2006: Foundational paper (Dwork, McSherry, Nissim, Smith — TCC)
- ε < 1: Typical "strong privacy" range (used by Census, Apple per-event)
- ε > 10: Typical "weak privacy" range (noise is negligible, risk rises)
- Δf = 1: Count query global sensitivity (one record changes count by ≤1)
What ε actually bounds
Epsilon (ε) is not a probability or a percentage — it is a log-odds bound on distinguishability. Formally, for neighboring datasets D and D′ (identical except one person's record is added, removed, or changed), and for every possible outcome S the mechanism could produce:
Pr[M(D) ∈ S] ≤ e^ε × Pr[M(D′) ∈ S]
At ε = 0.1, e^0.1 ≈ 1.105 — the presence of any one patient can shift the probability of any published outcome by at most about 10.5%. At ε = 1, e^1 ≈ 2.72 — a much looser bound. At ε = 10, e^10 ≈ 22,026 — the bound is so loose it provides almost no practical protection, since the mechanism's output can differ enormously depending on one record.
Crucially, ε is worst-case and composable: it holds regardless of what auxiliary information (voter files, genomic databases, social media) an attacker already has, and regardless of how many other queries have already been answered — which is precisely the property that defeats the linkage attacks from Stage 1.
Global sensitivity — how much can one record move the answer?
Before adding noise, a data curator must compute the query's global sensitivity Δf: the maximum amount the true answer can change when a single individual's record is added or removed, across all possible neighboring datasets.
• COUNT queries ("how many patients have diabetes?"): Δf = 1 — one person joining or leaving changes the count by exactly one. • SUM queries ("total inpatient days across the cohort"): Δf = the maximum possible value one person can contribute (e.g., capped at 365 days) — unbounded sums have unbounded, and therefore un-noisable, sensitivity. • AVERAGE / MEAN queries: typically split into a noised sum and a noised count, since the sensitivity of a raw average is not well-behaved when the group size itself is small or private. • Histogram/contingency-table queries: Δf = 1 per cell if a person contributes to only one bucket — the mechanism noises every cell independently.
This is why unbounded or poorly-capped queries ("total lifetime healthcare spend," with no cap) are dangerous under DP: an unbounded sensitivity forces either enormous noise or an unsound privacy guarantee. Real deployments cap or clip contributions (e.g., top-coding inpatient days at 365) specifically to keep Δf finite and small.
The noise scale in the Laplace mechanism is exactly Δf/ε. This single fraction is the entire "budget dial" of differential privacy: raise the sensitivity or lower ε, and the required noise — and therefore the statistical error the researcher must tolerate — grows in direct, calibrated proportion.
Choosing ε in practice is a policy decision, not just a math one
Unlike a cryptographic key length, there is no universally "safe" value of ε — it is a genuine privacy/utility policy tradeoff, and organizations disclose wildly different choices:
• Apple (iOS/macOS telemetry, since 2016): per-event ε values around 2–16 depending on data type (emoji suggestions, health app data, Safari energy draw), independently measured by Tang, Korolova, Bai, Wang & Wang (2017, USENIX Security) via source-code analysis, since Apple did not initially disclose exact values. • US Census Bureau (2020 Census, redistricting data release): adopted a total person-level privacy-loss budget of ε ≈ 19.61, allocated across a hierarchy of geographic levels (national, state, county, tract, block) via the TopDown Algorithm — controversial among demographers for being far looser than academic "strong privacy" recommendations of ε < 1. • Google RAPPOR (Chrome telemetry, 2014): designed around ε = ln(3) ≈ 1.10 per reported bit, deliberately conservative because reports are collected repeatedly over time.
The common thread: ε must be chosen jointly by privacy engineers, statisticians, and policy stakeholders, disclosed publicly, and re-evaluated whenever the mechanism or dataset changes.
The Laplace and Gaussian Mechanisms — Calibrating Noise to Sensitivity
The Laplace mechanism is the canonical construction that achieves pure ε-differential privacy: add random noise drawn from a Laplace distribution, centered at zero, with scale b = Δf/ε, directly to the true numeric answer before release. The Gaussian mechanism instead adds Normal-distributed noise and achieves the slightly relaxed (ε,δ)-differential privacy, which is more amenable to composing over many queries — the form used in most large-scale production systems.
- b = Δf/ε: Laplace noise scale (larger ε ⇒ tighter noise)
- ∝ e^(−|x|/b): Laplace PDF (symmetric, heavier tails than Gaussian)
- δ: Gaussian mechanism adds (small failure probability, typically 10⁻⁵–10⁻⁹)
- 0.5–1.5: DP-SGD noise multiplier (typical) (training models on patient records)
How the Laplace mechanism works, step by step
For a numeric query f with global sensitivity Δf, releasing:
M(D) = f(D) + Lap(Δf / ε)
where Lap(b) is a random draw from the Laplace distribution with probability density p(x) = (1/2b)·e^(−|x|/b), b = Δf/ε.
Worked example: a hospital wants to publish "number of patients readmitted within 30 days this quarter." True count = 214, Δf = 1 (one patient changes the count by exactly 1). At ε = 1, noise scale b = 1, so the published count is 214 + a draw from Lap(1) — typically off by only ±1–2 in practice, but occasionally further out, since Laplace tails are heavier than a Gaussian's. At ε = 0.1 (a much stronger guarantee), b = 10, and typical error grows roughly tenfold.
The mechanism provably satisfies pure ε-DP because the ratio of densities p(x)/p(x−1) is bounded exactly by e^(1/b) = e^ε for any shift of at most Δf — which is exactly the worst-case effect one record can have. This is not an approximation; it is an algebraic identity of the Laplace distribution, which is why it was the first mechanism formalized in the 2006 Dwork–McSherry–Nissim–Smith paper.
A useful intuition: at ε = 0.1, a released statistic is so noisy that an attacker cannot distinguish "your relative had this diagnosis" from "they didn't" with better than roughly 52.5% confidence, even with unlimited side information and unlimited other queries. At ε = 10, that confidence can approach certainty — which is why regulators increasingly ask organizations to disclose their ε value the way they would disclose an encryption standard.
The Gaussian mechanism and (ε, δ)-differential privacy
Most production systems — including Apple's and Google's — use a relaxed definition, (ε, δ)-differential privacy, satisfied by adding Gaussian (Normal) noise: N(0, σ²) with σ calibrated to Δf, ε, and a small failure probability δ (typically 10⁻⁵ to 10⁻⁹, roughly interpreted as "the guarantee could catastrophically fail with this tiny probability").
Why accept a looser guarantee? Two practical reasons:
1. Gaussian noise composes more efficiently over many queries than Laplace noise under "advanced composition" theorems — critical when a health system needs to answer hundreds of research queries against the same cohort over months.
2. Gaussian mechanisms are the natural fit for training machine learning models on patient data via DP-SGD (Differentially Private Stochastic Gradient Descent, Abadi et al., 2016): each mini-batch gradient is clipped to bound per-patient sensitivity, then Gaussian noise is added before the model update, and a "moments accountant" (later superseded by Rényi DP accounting) precisely tracks cumulative ε across potentially millions of training steps — used when hospitals or the NIH All of Us Research Program train diagnostic or risk-prediction models directly on identifiable clinical records without ever releasing the raw data.
Central vs. local differential privacy
There are two fundamentally different trust models for where the noise gets added:
• Central (or "curated") DP: raw patient records are collected by a trusted curator (e.g., the hospital, the Census Bureau) who computes the true statistic first, then adds noise once before publishing. Noise scales with Δf/ε only once per query — much less noise is needed for the same ε, because the curator only needs to protect the final release, not every individual transmission.
• Local DP: each patient's device or record is noised before it ever leaves their control — the curator never sees true individual values, only noisy ones, and aggregates over many noisy reports. This requires far more noise per record to reach the same guarantee (noise doesn't average away as cleanly), but it protects patients even from a curator who is compromised, subpoenaed, or malicious. Apple's and Google's consumer deployments (Stage 5) use local DP for exactly this reason — Apple never wants to be able to hand a court a database of raw per-user telemetry.
Health-data research consortia (multi-hospital registries, the NIH, insurance claims warehouses) more often use central DP, because a single accountable, audited data-use agreement already exists — the tradeoff is that the curator itself becomes a high-value target that must be secured.
Composition Theorems and the Accuracy–Privacy Tradeoff
A privacy budget ε is not spent once — it is spent every time the dataset is queried, and the losses accumulate. Sequential composition theorems prove that k independent ε-DP queries against the same dataset together satisfy kε-differential privacy (or roughly √k·ε under tighter "advanced composition" bounds). This turns data governance into an explicit accounting problem: a finite budget must be rationed across every research question the dataset will ever be asked.
- Σεᵢ: Sequential composition (basic) (k queries ⇒ total = ε₁+ε₂+...+εₖ)
- ≈√k·ε: Advanced composition (tighter) (for k queries at fixed ε, large k)
- tightest: Rényi DP accounting (DP-SGD) (used for ML training over many steps)
- ε ≤ 1–3: Typical research-program budget (total, across all releases, per dataset)
Why composition forces rationing
If a curator answers query 1 with ε₁-DP and query 2 with ε₂-DP against the same underlying dataset, the basic sequential composition theorem proves the combined release satisfies (ε₁+ε₂)-DP — privacy loss is additive in the worst case. Answer 20 queries at ε=0.5 each, and the cumulative guarantee is only ε=10, which per Stage 2's intuition is barely protective at all.
This has a direct, uncomfortable consequence for health research: every dataset has a privacy "budget" that is consumed and cannot be replenished. Once ε is exhausted, the only options are to stop answering queries against that dataset, accept a weaker (larger ε) guarantee going forward, or collect a fresh dataset. This is why production DP systems (Census, Apple, Google) treat the total budget as a first-class governed resource — tracked, capped, and reported — the same way a company tracks a compute or a financial budget.
Advanced composition theorems (Dwork, Rothblum & Vadhan, 2010) prove a tighter bound of roughly ε√(2k·ln(1/δ′)) + kε(e^ε−1) for k queries, which grows only with the square root of k rather than linearly — a critical improvement that lets systems answer far more queries before exhausting budget, at the cost of a slightly relaxed (ε,δ) guarantee rather than pure ε-DP.
The accuracy cost is not abstract — it shows up in published numbers
Demographers analyzing the 2020 Census's DP-protected redistricting data found concrete distortions directly attributable to the noise-vs-privacy tradeoff:
• Small racial and ethnic subpopulations in sparsely populated rural counties showed the largest relative errors — a group of 12 people in a block could be reported as 8 or 17, materially changing local diversity statistics, because Laplace/Gaussian noise scale does not shrink with population size the way sampling error does. • Group quarters populations (prisons, college dorms, nursing homes) — inherently small, geographically concentrated counts — needed special-case "invariants" (exact, un-noised totals) written into the TopDown Algorithm to keep basic accounting (total state population for apportionment) exactly correct, illustrating that pure DP and exact legal/statutory requirements can directly conflict. • Tribal nations and some state demographers formally objected during the Bureau's 2019–2021 public comment process, arguing the chosen ε over-prioritized privacy at the expense of data long relied on for Voting Rights Act enforcement and resource allocation — a real, unresolved policy tension between two legitimate goods.
This is the essential lesson of Stage 4: ε is not a knob a data scientist tunes in isolation — moving it trades off against specific, real downstream harms (bad resource allocation, unusable subgroup statistics, weakened civil-rights enforcement data) that must be weighed against specific, real privacy harms (re-identification, discrimination, insurance/employment risk from health status disclosure).
A rule of thumb used by several DP practitioners: for a COUNT query, the Laplace mechanism's error is roughly comparable in magnitude to the sampling error of a simple random survey of size n ≈ ε² × (true count), meaning DP-noised statistics on small subgroups behave statistically like survey estimates from a much smaller sample — useful for population-level trends, unreliable for small-cell health statistics unless ε is generously budgeted for that cell specifically.
Budget allocation strategies used in practice
Real deployments rarely spend a flat ε per query; they allocate the total budget strategically:
• Geographic/hierarchical splitting: the 2020 Census TopDown Algorithm allocates the total ε ≈ 19.61 unevenly across national, state, county, tract, and block levels — coarser geographies get more of the budget (tighter noise) because they are queried more and support more downstream uses, while block-level data gets comparatively less. • Query caps and per-analyst budgets: research data-use agreements (common in NIH-funded consortia) assign each approved analyst or study protocol its own sub-budget, so one over-eager researcher cannot exhaust the privacy protection for everyone else querying the same clinical warehouse. • Sparse vector technique / threshold-based release: only publish an answer (and only spend budget) if the query result exceeds a noisy threshold — used when most possible research questions will yield uninteresting answers, so budget is reserved for the queries that matter. • Renewable budgets via fresh cohorts: some registries (e.g., annual influenza surveillance) treat each year's enrollment as effectively a new dataset, resetting ε, rather than treating a running longitudinal cohort as one dataset queried forever — trading longitudinal analytic power for a replenished budget.
Differential Privacy in Production — Census, Apple, and Beyond
Differential privacy left academic papers and entered daily use at population scale starting in the mid-2010s. Three deployments illustrate the range of real trade-offs organizations make: the US Census Bureau's central-DP redistricting release, Apple's local-DP device telemetry, and Google's RAPPOR — each spending a disclosed epsilon to answer real questions about real populations, including health-adjacent ones, without exposing individuals.
- ≈19.61: 2020 US Census total person-ε (TopDown Algorithm, redistricting file)
- 2016: Apple local-DP launch (iOS 10 / macOS Sierra)
- 2014: Google RAPPOR launch (Chrome usage statistics)
- 2023: NIST DP guidelines published (SP 800-226 (draft))
The US Census Bureau — differential privacy at national scale
The 2020 Decennial Census was the first constitutionally mandated US data collection protected end-to-end by differential privacy, replacing the Bureau's prior "swapping"-based disclosure avoidance system after Bureau researchers John Abowd and colleagues demonstrated — using the same reconstruction-attack techniques an adversary could use — that the 2010 methodology could re-identify a large share of individuals when combined with commercial datasets.
The Bureau's TopDown Algorithm applies noised counts at the national level first, then works down through states, counties, census tracts, and blocks, enforcing consistency (noised child geographies must sum to their noised parent) and a set of legally required "invariants" — total state population counts used for congressional apportionment are never noised, since the Constitution requires exact figures for that specific purpose. Total allocated privacy-loss budget for the redistricting data release: ε ≈ 19.61, split across geographic levels and statistical tables — controversial precisely because it is far looser than the ε < 1 many DP researchers consider "strong" privacy, reflecting the real political and legal pressure to preserve data utility for redistricting and Voting Rights Act enforcement.
Apple and Google — local differential privacy on billions of devices
Apple introduced local differential privacy in iOS 10 and macOS Sierra (2016) to collect aggregate usage statistics — including Health app data types, emoji suggestions, and Safari energy-draining domains — without any raw per-user data ever leaving the device unnoised. Apple's technique layers count-mean-sketch and hash-based privatization on top of local DP noise, and independent researchers (Tang, Korolova, Bai, Wang & Wang, USENIX Security 2017) reverse-engineered the shipped implementation to find per-event ε values ranging roughly from 2 (health-type data, more conservative) to 16 (some macOS telemetry, looser than Apple's public materials implied) — a widely cited example of the gap between a stated privacy narrative and an audited, disclosed parameter.
Google's RAPPOR (Randomized Aggregatable Privacy-Preserving Ordinal Response, Erlingsson, Pihur & Korolova, CCS 2014) used randomized-response-based local DP to collect Chrome browser statistics — home page settings, process names — designed around ε = ln(3) ≈ 1.10 per bit reported, deliberately conservative because RAPPOR reports are collected repeatedly over time and composition (Stage 4) erodes the guarantee with every report.
LinkedIn's PriPeARL system and Microsoft's telemetry pipelines have published similar local- and central-DP designs for workplace and product-usage analytics, and multiple health systems and the NIH-funded All of Us Research Program have piloted DP-protected cohort-discovery tools that let external researchers run aggregate queries against genomic and clinical data without ever downloading identifiable records.
NIST published Special Publication 800-226, "Guidelines for Evaluating Differential Privacy Guarantees," in December 2023 — the first US federal technical standard giving agencies and vendors a common vocabulary and evaluation checklist for claimed DP systems, explicitly warning that many commercial "differential privacy" products make unverifiable or misleading claims about their actual ε.
Where health-data sharing goes from here
Regulatory pressure is pushing health-adjacent data sharing toward disclosed, auditable guarantees rather than informal "de-identification":
• HIPAA's Safe Harbor and Expert Determination standards predate differential privacy and do not require or even mention an ε; ongoing HHS rulemaking discussions (including proposed updates following the 2023–2024 FTC health-privacy enforcement wave) have explored whether a quantifiable standard like DP should be recognized as a compliant de-identification method. • GDPR's Article 4 distinguishes "anonymous" data (outside GDPR's scope entirely) from "pseudonymous" data (still regulated); EU data protection authorities and the European Data Protection Board have issued guidance suggesting that only mechanisms with a formal, bounded re-identification guarantee — which DP provides and ad hoc "anonymization" does not — should qualify as truly anonymous. • Illinois' Biometric Information Privacy Act (BIPA) and similar state genetic-privacy laws (e.g., following the 23andMe breach) are pushing companies handling genetic and biometric health data toward provable technical safeguards, since statutory per-violation damages make weak anonymization commercially risky, not just ethically questionable.
The trajectory across Census, Apple, Google, and now health research infrastructure is consistent: move from "we removed the obvious identifiers and trust our judgment" toward "here is our disclosed ε, our sensitivity bound, and our composition accounting" — replacing a promise with a provable, auditable number.
Differential privacy in production — deployment comparison
| Product | Indication | Trial Design | Key Result |
|---|---|---|---|
| US Census (2020 TopDown) | Full US population, redistricting data | Central DP; hierarchical noised counts with consistency + invariants | ε≈19.61 total; legally exact apportionment totals preserved |
| Apple iOS/macOS telemetry | On-device usage, Health app, emoji, Safari | Local DP; count-mean-sketch + hashing before transmission | Per-event ε≈2–16; curator never sees raw values |
| Google RAPPOR (Chrome) | Browser settings, process telemetry | Local DP; randomized response on Bloom-filter bits | ε=ln(3)≈1.10 per bit; robust to repeated reporting |
| NIH All of Us (pilot cohort tools) | Genomic + EHR research cohort discovery | Central DP; noised aggregate counts on query interfaces | Enables count queries without raw record download |
This simulator demonstrates differential privacy techniques for sharing health datasets in research settings, ensuring that individual patient data remains private while still allowing useful statistical analysis.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install