Skip to content
tezvyn:
Menu

Differential privacy, epsilon, and noisy aggregates

Source: interviewHardHow cards are made

Summary

rigorous privacy guarantees.

Key points

define DP as bounded output change when one record is added or removed, explain epsilon as the privacy-accuracy knob, add calibrated noise scaled to sensitivity.

What's really being asked

This checks whether you grasp differential privacy as a mathematical guarantee about the mechanism, not a property of a dataset, and whether you can correctly calibrate noise to sensitivity and epsilon.

The full answer

Differential privacy guarantees that the output of a computation is almost unchanged whether or not any single individual's record is included. Formally, for any two datasets differing in one record, the probability of any output changes by at most a multiplicative factor of e to the epsilon. This means an adversary observing the result cannot confidently tell if a given person participated, which protects individuals even against attackers with arbitrary side knowledge, unlike k-anonymity. Epsilon is the privacy budget: a small epsilon adds more noise and gives strong privacy at the cost of accuracy, while a large epsilon adds little noise and gives weak privacy with high accuracy. The budget composes, so each query spends some epsilon and the total spent across queries is bounded. The mechanism adds random noise calibrated to the query's sensitivity, the maximum amount one record can change the output, divided by epsilon. For a count, sensitivity is one; for an average you bound salaries to a known range to make sensitivity finite.

A GOOD ANSWER COVERS the pseudocode in prose: define dp_average(salaries, epsilon, lower, upper). Clip each salary to the range lower to upper. Compute the true sum and the count n. Sensitivity of the sum is upper minus lower. Add Laplace noise with scale equal to sensitivity divided by epsilon to the sum, and add Laplace noise with scale one over epsilon to the count. Return the noisy sum divided by the noisy count.

The mistakes people make

Confusing DP with anonymization or k-anonymity. Adding noise without scaling it to sensitivity, which breaks the guarantee. Forgetting to clip salaries, leaving unbounded sensitivity. Ignoring that repeated queries deplete the budget.

What usually comes next

Why must you bound the salary range? How does the budget compose across many queries? What is the difference between local and central DP?

A concrete example

With epsilon set to one and salaries clipped to zero through five hundred thousand, you compute the true average, then add Laplace noise of scale five hundred thousand to the sum and small noise to the count before dividing. An analyst sees an average close to the truth, but no one can determine whether any specific employee was in the table.

Interview question

In differential privacy, what does decreasing epsilon (the privacy budget) do?

  • a.Guarantees the exact true value is returned
  • b.Strengthens privacy by adding more noise, reducing output accuracyCorrect
  • c.Has no effect on noise, only on query count
  • d.Weakens privacy and improves accuracy
Why?

Smaller epsilon means a tighter bound on how much one record can affect the output, achieved by adding more noise, so privacy rises and accuracy falls. Larger epsilon does the opposite; epsilon directly controls the noise magnitude.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles