/knowledge/notes/synthetic-data
Concept note · Data Governance, Privacy & Ethics
Synthetic Data
Rows drawn from a model instead of copied from the data. What a generator keeps, what it drops, and the two checks I run before trusting a synthetic table.
- Studied
- Synthetic test and stand-in dataIn practice
- When
- 2025–2026
- Applied in
- SA Mock Address Lab · HPLC QC Lab
- Read / Refreshed
- ~6 min read2026-10-21
Three of the demos on this site run on data that never existed. The rows look like lab results, street addresses or a month of daily check-ins, and none of them came from a person or a partner organisation. Each time that was a choice, because the real data could not leave the place it lived. This note covers how a generator makes rows like these, what it keeps and what it quietly drops, and the checks I run before I trust a synthetic table.
01
The idea
Synthetic data is drawn from a model of the data rather than copied out of the data. The model can be written by hand, as a set of rules and distributions you choose, or it can be fitted, learned from real rows. Either way the synthetic rows are new draws, so no row has to belong to anyone.
It gets used for two quite different jobs. The first is as a stand-in for data you are not allowed to share: patient records, a partner's lab exports, anything under a privacy or confidentiality promise. The second is as test data where you control the truth. If you plant a fault in row 412 on purpose, you know exactly what a good detector should flag, which real data never tells you. The second job does not need any real data at all.
The catch is the same in both. A generator can only give back what its model holds. A relationship between two columns that the model leaves out is missing from every synthetic row, and drawing a million rows will not bring it back. The opposite failure is just as real: a generator that holds too much is a copy of the real rows with extra steps. So every synthetic table faces two questions that pull against each other. Is it close enough to the real thing to be useful, which is its fidelity? And is it far enough from the real rows to be safe, which is its disclosure risk?
02
The maths
Real rows come from some unknown distribution . A generator fits a model to them and then draws new rows from the model.
Whatever the fitted model cannot express, no synthetic row will contain.
For fidelity, compare the two samples as distributions rather than comparing a few summary numbers. A plain way is to cut the space into cells, take the share of real rows and synthetic rows in each, and add up the differences. This is the total variation distance.
0 means the shares match in every cell. 1 means the two samples never share a cell.
A score on its own means little, because two honest samples from the same source also differ. The baseline is a second, fresh sample of real data, held out from the generator. If the synthetic rows land near the fresh sample's score, the generator is about as good as it can be on this measure. If they score much better than fresh real data, be suspicious, because the likeliest way to beat a fresh sample is to copy the training rows.
For disclosure, the simplest check is the distance to the closest record. For each synthetic row, find the nearest real row.
Compare the spread of these distances with the same distances for fresh real rows.
Fresh real rows sit at some typical distance from the training rows. Synthetic rows that sit much closer than that are leaking individual records, and a distance of exactly zero means a real row has been published as it was.
When the target is a mix of categories rather than a cloud of points, the fidelity check becomes a goodness-of-fit test. Count the observed rows in each of categories, compare them with the counts the target mix expects, , and report the effect size next to the p-value so a large sample cannot make a trivial gap look important.
Pearson's test with K − 1 degrees of freedom, valid when every expected count is at least about 5.
03
Try it
The real data in the widget is made up too: 100 rows from three clusters. Each generator learns from those rows and draws 100 new ones. The table scores the synthetic rows next to a fresh draw from the same three clusters, the best result any generator could hope for.
Generator
- Real rows
- Synthetic rows
Faint lines mark the 5 × 5 grid the shape gap is counted on.
The real rows have a correlation of 0.55.
The Normal generator gives a correlation of 0.61 against the real 0.55. Its shape gap of 0.53 is well above the 0.16 a fresh real sample scores, so the shape is lost. Its rows sit further from real rows than fresh real data does (0.174 against 0.033), so little is copied.
| Rows | r | Shape gap | Nearest real | Copies |
|---|---|---|---|---|
| Fresh real sample | 0.57 | 0.16 | 0.033 | 0 |
| Normal generator | 0.61 | 0.53 | 0.174 | 0 |
- Start on Normal. Its correlation lands close to the real one, yet its shape gap is the worst of the three, because one normal distribution fills the empty space between the clusters. Matching a summary statistic proves very little.
- Switch to Shuffle. Each column keeps its exact values, the correlation falls to about zero, and a cluster appears in the top-left corner where the real data has none.
- Switch to Copy and drag σ to 0. The shape gap now beats the fresh real sample and all 100 rows are copies. Perfect fidelity is the privacy failure.
- Raise σ slowly. Near 0.05 the median distance to the nearest real row matches the fresh sample. Past 0.2 the clusters blur and the shape gap climbs.
- On some seeds, including the first, Shuffle rebuilds one real row exactly, purely by chance. A generator does not have to copy on purpose to publish a real record.
04
Where I used it
05
Easy to get wrong
06
Sources
- Synthetic Data: what, why and how?Jordon, Szpruch, Houssiau and others, arXiv:2205.03257, 2022.A broad, readable report on what synthetic data can and cannot promise, written for the Royal Society. Good on the fidelity, utility and privacy trade-off.
- synthpop: Bespoke Creation of Synthetic Data in RNowok, Raab and Dibben, Journal of Statistical Software, volume 74, issue 11, 2016.A practical package and paper from the official statistics world. It fits one column at a time, conditioned on the ones before, and comes with utility checks.
- Synthetic Data: Anonymisation Groundhog DayStadler, Oprisanu and Troncoso, USENIX Security Symposium, 2022.The paper to read before calling a synthetic release private. It attacks several generators and shows that unusual records stay exposed.