Exercises — Privacy (differential privacy, membership inference)
This page is a self-test ladder for Privacy (differential privacy, membership inference). Work each problem first, then open the solution. Every symbol used here was built in the parent note; where a formula reappears we restate it in one line so you never have to scroll back.
Level 1 — Recognition
Exercise 1.1
State, in words, what the inequality guarantees, where differ in one record.
Recall Solution
is a randomized mechanism (an algorithm whose output is random). and are neighboring datasets — identical except one person's row. The line says: for any set of outputs you might look at, the probability of landing in changes by at most a multiplicative factor of when one individual is added or removed. Consequence: an adversary watching the output cannot tell "was this person in the data?" with much confidence, because both worlds produce nearly the same output distribution.
Exercise 1.2
For the Laplace mechanism , which quantity do you plug into : , , or the ratio ? Explain why the ratio and not just .
Recall Solution
You set . Why the ratio: the noise must be big enough to hide the biggest one-person change , and how thoroughly we hide it is governed by our budget . A tight budget (small ) demands more blur, so grows. A large tolerable change also demands more blur. Dividing puts both pressures in one number.
Exercise 1.3
True/False: Gaussian noise gives pure -DP. Justify.
Recall Solution
False. The pure-DP bound needs the ratio of the two noise densities to be capped by everywhere. The Laplace density decays like , so the log-ratio is a bounded straight line — capped. The Gaussian density decays like ; its log-ratio grows linearly without bound as , so no finite caps it. Gaussian therefore only gives -DP (approximate DP), where a small failure probability absorbs the uncontrolled tail. See the figure.

Level 2 — Application
Exercise 2.1
Release the mean of salaries, each in [0,\200{,}000]\varepsilon=2.0\Delta fb$.
Recall Solution
Sensitivity. Adding/removing one salary moves the sum by at most $200{,}000. The mean divides by , so Scale. So — noise of a few hundred dollars on a salary mean: negligible, strong privacy.
Exercise 2.2
A counting query "how many patients have diabetes?" is released with . Sensitivity of any count under add/remove is . What is , and roughly how large is the typical noise?
Recall Solution
The Laplace mean absolute deviation equals , so typical error is about people. For a large hospital count this is tiny — counts are cheap to privatize because .
Exercise 2.3
Same diabetes count, but now you release it twice (two separate noisy answers), each with . What total does an adversary who sees both face? (Use basic composition.)
Recall Solution
Basic composition rule: running mechanisms with budgets and combining their outputs costs at most . Here . Why additive and not multiplicative: the log of the probability ratio is what adds. Two independent releases multiply their factors (), and multiplying -powers means adding exponents.
Level 3 — Analysis
Exercise 3.1
Prove the Laplace mechanism achieves -DP for a scalar query with sensitivity , by bounding the density ratio at an arbitrary output .
Recall Solution
Let neighbors give with . The Laplace density is , so at output : By the reverse triangle inequality, . Hence the exponent . Choose : The bound holds at every , so integrating over any set preserves it. Figure shows the two shifted densities and the largest gap between their logs.

Exercise 3.2
Under replace-one neighbors, a summed query can change by two records. If a single record moves the sum by at most , what is , and how does compare to the add/remove case?
Recall Solution
Replace = remove old (up to ) + add new (up to ) . Then — twice the noise of add/remove (). Same , but replace-one is the stricter neighbor definition, so it costs more blur. Always state which definition you use.
Exercise 3.3
In DP-SGD the per-example gradient is clipped to norm and Gaussian noise of std is added to the sum of a batch of clipped gradients, then divided by . Show that the noise on the averaged gradient has std per coordinate. Why does the sensitivity of the sum equal (add/remove)?
Recall Solution
Sensitivity of the sum: removing one clipped gradient (norm ) from changes it by a vector of length , so . Noise on the average: we add to the sum, then multiply the whole thing by . Scaling a Gaussian by constant scales its std by : This is the same mechanism described two ways — noise calibrated to the sum's sensitivity , then averaged.
Level 4 — Synthesis
Exercise 4.1
Run the parent's DP-SGD accounting formula with , , , . Report .
Recall Solution
. ; square root . So this run spends roughly — a moderate budget. (In the parent example this is why was chosen rather than : bigger shrinks .)
Exercise 4.2
Using the same formula, you want to halve (from to ) while keeping fixed. What must become? Then explain qualitatively what that does to model accuracy.
Recall Solution
at fixed . To halve , double : . Check: . ✓ Accuracy cost: noise std on the average gradient is , so doubling doubles the gradient noise. Training is noisier, convergence slower, final accuracy lower. This is the fundamental privacy–utility trade-off.
Exercise 4.3
The formula scales as , not . If you train for as many steps (same ), by what factor does grow? Contrast with what basic composition (linear) would predict.
Recall Solution
Advanced composition: , so steps the budget. Basic composition would predict , i.e. . The savings come because privacy losses of independent steps partly cancel (like a random walk: steps travel distance , not ). Subsampling () amplifies this further since each person appears in only a fraction of batches.
Level 5 — Mastery
Exercise 5.1
A hospital releases: (a) a diabetes count at (), and (b) a mean age at (, since ages in , , add/remove). Give the total budget under basic composition, and the two Laplace scales.
Recall Solution
Scales: count ; mean age . Total budget: basic composition adds : . Interpretation: an adversary seeing both noisy answers faces at most a -DP guarantee overall.
Exercise 5.2
You have a fixed total budget and must answer identical count queries ( each). Under basic composition you split the budget evenly. Find the per-query , the per-query Laplace scale , and comment on the noise growth as increases.
Recall Solution
Even split: . Scale: . As grows, , so : noise grows linearly in the number of queries. This is the pressure that motivates advanced composition and subsampling — basic splitting is wasteful.
Exercise 5.3
Membership-inference sanity check. An attacker guesses "was record in the training set?" by thresholding the model's confidence. Suppose the mechanism is truly -DP with . What is the maximum advantage (accuracy above random guessing 50%) the attacker can achieve? Explain via the DP inequality.
Recall Solution
With , , so for every output set : The two worlds are identical distributions — no observation distinguishes them. The attacker's best strategy is a coin flip: 50% accuracy, 0% advantage. DP directly caps membership-inference success; larger loosens this cap monotonically.