Search

Search papers and lessons

Gaussian Mechanism

Level 3 · 10 min read

The Gaussian mechanism answers a query plus bell-curve noise whose width is set by the query's L2 global sensitivity, giving approximate differential privacy.

On this page

  • Colour = topic mix
  • Discrete math
  • Probability
  • Calculus
  • Linear algebra
  • Security & cryptography
  • ReadReady to readNot yet

TL;DR

The Gaussian mechanism releases a query's true answer plus random noise drawn from a bell curve. The width of that curve is set by the query's L2 Global Sensitivity, so a query that can move a lot gets more noise. The result is a guarantee called approximate differential privacy, with two numbers ε\varepsilon and δ\delta that say how much a single person's data can show.

Builds on: Global Sensitivity, Gaussian (Normal) Distribution · Leads to: Differential Privacy

Where it's used

Training neural networks with privacy. In DP-SGD, a training method from Abadi and colleagues in 2016, each example's Gradient is clipped to a fixed length. The clipped gradients are summed for a batch, and Gaussian noise is added to that sum before the model update. The clip length is the sensitivity, so the noise can be scaled to it.

Releasing statistics about groups. A health or public-policy team may publish averages, counts or histograms of a dataset. Releasing the exact numbers would reveal whether a particular person is in the data, so the team adds Gaussian noise calibrated to how much one record can change each published number.

Analytics on user devices. A product team that wants aggregate usage numbers from many phones can have each phone add its own noise before sending a value, so that the server never sees an exact individual contribution. The noise each device adds is still the Gaussian mechanism, applied locally to its own value.

How it works

Take one count, add noise, and see what the released number looks like.

  1. Compute the true answer. A query counts how many people in a dataset visited a clinic last week. The true count is f(D)=40f(D) = 40.
  2. Find the sensitivity. Adding or removing one person changes the count by at most 1, so the L2 global sensitivity is Δ2f=1\Delta_2 f = 1. Check: a count can move by 1 when one person is added.
  3. Choose the noise width. The privacy target fixes a noise standard deviation σ\sigma in proportion to the sensitivity. Suppose the target gives σ=2\sigma = 2 here. Check: a bigger sensitivity means a wider curve.
  4. Draw the noise. Sample one value zz from a normal distribution with mean 0 and standard deviation 2. Suppose the draw is z=−0.8z = -0.8. Check: most draws fall within about two standard deviations, so between −4-4 and 44.
  5. Add and release. Publish 40+(−0.8)=39.240 + (-0.8) = 39.2, not 40.
  6. Read the result. The released number is close to the truth, and any single person's presence is hidden by the noise width. Check: a neighbouring dataset gives a true count of 41 or 39, and the released value still has a similar spread.
flowchart LR
  A[Dataset D] --> B[True answer f of D]
  A --> C[L2 global sensitivity]
  C --> D[Noise width sigma]
  D --> E[Draw noise z]
  B --> F[Add noise]
  E --> F
  F --> G[Release]

The math

Definition

Definition: Gaussian mechanism

Let ff be a query with L2 global sensitivity Δ2f\Delta_2 f. The Gaussian mechanism releases

M(D)=f(D)+Z,Z∼N(0,σ2I),\mathcal{M}(D) = f(D) + \mathbf{Z}, \qquad \mathbf{Z} \sim \mathcal{N}(\mathbf{0}, \sigma^2 \mathbf{I}),

where Z\mathbf{Z} is a multivariate normal vector of independent normal values, each with mean 0 and standard deviation σ\sigma, and I\mathbf{I} is the identity matrix that makes the noise independent in each coordinate.

The symbol N(0,σ2I)\mathcal{N}(\mathbf{0}, \sigma^2 \mathbf{I}) reads "normal distribution with mean zero and covariance σ2I\sigma^2 \mathbf{I}". A Gaussian is fully set by its mean and variance, and here the variance is σ2\sigma^2.

Step 1 in symbols: the true answer

Compute f(D)f(D) on the actual dataset. For the count, f(D)=40f(D) = 40. This number is what the mechanism hides.

Step 2 in symbols: the sensitivity

The change in the answer for a neighbouring dataset has L2 size at most Δ2f\Delta_2 f, as defined in Global Sensitivity. For a scalar count, the L2 size is just the absolute change, so Δ2f=1\Delta_2 f = 1.

Step 3 in symbols: the noise width

The privacy guarantee is stated with two numbers. ε>0\varepsilon > 0 says how much the output distribution may shift when one record is changed; smaller is more private. δ\delta is a small probability allowance for rare events where that shift is larger. The standard sufficient condition for (ε,δ)(\varepsilon, \delta)-differential privacy, valid when 0<ε<10 < \varepsilon < 1, is

σ≥c Δ2fε,c2>2ln⁡ ⁣(1.25δ).\sigma \ge \frac{c \, \Delta_2 f}{\varepsilon}, \qquad c^2 > 2 \ln\!\left(\frac{1.25}{\delta}\right).

In words: the noise must grow with the sensitivity, and it must shrink as the allowed leakage ε\varepsilon grows. The ln⁡\ln term grows slowly as δ\delta gets smaller.

−6−4−2024600.10.20.30.4noise zdensity
  • sigma = 1
  • sigma = 2
Doubling sigma flattens the bell curve and spreads the noise twice as wide. Both curves still have area 1.

Step 4 in symbols: draw and add

Sample z\mathbf{z} from N(0,σ2I)\mathcal{N}(\mathbf{0}, \sigma^2 \mathbf{I}) and output f(D)+zf(D) + \mathbf{z}. Each coordinate of z\mathbf{z} is an independent normal value. For a scalar count, it is a single normal draw.

Worked examples

Example
Example 1: one noisy count

The true count is f(D)=40f(D) = 40, the sensitivity is Δ2f=1\Delta_2 f = 1, and the chosen noise standard deviation is σ=2\sigma = 2.

  1. Draw one noise value zz from a normal distribution with mean 0 and standard deviation 2.
  2. Suppose the draw is z=1.5z = 1.5.
  3. Release 40+1.5=41.540 + 1.5 = 41.5.
  4. Check the size: the noise was 1.5, which is less than one standard deviation, so the output is a typical draw.
  5. Conclusion: the released count is 41.5. Repeating the release with a new draw gives a different number each time, which is the point of the mechanism.
Example
Example 2: calibrating sigma

Take Δ2f=1\Delta_2 f = 1, ε=0.5\varepsilon = 0.5 and δ=10−5\delta = 10^{-5}.

  1. Compute the log term: ln⁡(1.25/10−5)=ln⁡(125000)\ln(1.25 / 10^{-5}) = \ln(125000). Since ln⁡(125000)=ln⁡(1.25)+ln⁡(105)≈0.2231+11.5129=11.736\ln(125000) = \ln(1.25) + \ln(10^5) \approx 0.2231 + 11.5129 = 11.736.
  2. Double it: 2×11.736=23.4722 \times 11.736 = 23.472, so c2>23.472c^2 > 23.472.
  3. Take the square root: c>23.472≈4.845c > \sqrt{23.472} \approx 4.845.
  4. Divide by ε\varepsilon and multiply by the sensitivity: σ≥4.845×1/0.5=9.69\sigma \ge 4.845 \times 1 / 0.5 = 9.69.
  5. Conclusion: a noise standard deviation of about 9.7 gives (0.5,10−5)(0.5, 10^{-5})-differential privacy for this count.
  6. Compare: halving ε\varepsilon to 0.25 doubles the required σ\sigma to about 19.4, because σ\sigma is proportional to 1/ε1/\varepsilon.
Example
Example 3: a clipped gradient sum in training

A model is trained on mini-batches. Each example's gradient is clipped so its L2 length is at most C=1C = 1. The batch sum is the query, and adding or removing one example changes it by at most CC in L2, so Δ2f=1\Delta_2 f = 1. Use a noise multiplier of 1.1, so σ=1.1×C=1.1\sigma = 1.1 \times C = 1.1 per coordinate. The batch has 4 examples, and the clipped sum is (0.6,−0.2)(0.6, -0.2).

  1. Draw noise z=(0.4,−1.3)\mathbf{z} = (0.4, -1.3) from N(0,1.12I)\mathcal{N}(\mathbf{0}, 1.1^2 \mathbf{I}). The draw is an illustration, not a sample from a seeded generator.
  2. Add it to the sum: (0.6+0.4,−0.2−1.3)=(1.0,−1.5)(0.6 + 0.4, -0.2 - 1.3) = (1.0, -1.5).
  3. Divide by the batch size 4 to get the averaged update direction: (0.25,−0.375)(0.25, -0.375).
  4. Each coordinate of the noisy sum has standard deviation 1.1, so the noise is large compared with the true sum of 0.6 and -0.2. This is the cost of privacy, and it is why batch size matters.
  5. Conclusion: the update uses noisy but privacy-protected gradients, and every released sum is calibrated to the clip length.

Try it: the clip length is C=0.5C = 0.5 and the noise multiplier is 2. What is the noise standard deviation per coordinate?

Answer: σ=2×0.5=1.0\sigma = 2 \times 0.5 = 1.0.

Common mistakes and tradeoffs

Mistake 1: using the L1 sensitivity. The difference between the L1 and L2 norms matters here. It is tempting to plug in whichever sensitivity is at hand. In fact the Gaussian mechanism is calibrated to the L2 sensitivity Δ2f\Delta_2 f. The L1 size of a change is never smaller than its L2 size, so noise calibrated to L1 is still private, but it is needlessly large. The L1 sensitivity is the natural input for the Laplace mechanism, a different method.

Mistake 2: thinking the guarantee is pure. It is tempting to read ε\varepsilon as the whole story. In fact the Gaussian mechanism gives approximate privacy, and δ\delta is a real allowance for rare events where the leakage is worse than ε\varepsilon. A safe choice makes δ\delta much smaller than one over the number of records, so that a small group cannot be exposed with high probability.

Mistake 3: forgetting that repeated releases add up. It is tempting to treat each release as private on its own. In fact every release leaks some information, and the privacy costs accumulate across queries and training steps. Systems track a total budget for this reason.

Mistake 4: clipping after noise. It is tempting to add noise first and clip later. In fact the sensitivity bound only holds if each record's contribution is clipped before the sum, so the clip must come first.

Tradeoffs. A larger ε\varepsilon means less noise and weaker privacy. A smaller δ\delta costs only a logarithm, so it is cheap to make it small. A tighter analysis of the same mechanism can give less noise for the same guarantee.

When to use it. Use the Gaussian mechanism when the query has a finite L2 sensitivity, and approximate privacy is acceptable. It is the usual choice for high-dimensional outputs such as gradient sums.

When not to use it. When you need pure ε\varepsilon-privacy with δ=0\delta = 0, the Laplace mechanism is the usual alternative for queries with a small L1 sensitivity.

History

Differential privacy was formalised in 2006 by Cynthia Dwork, Frank McSherry, Kobbi Nissim and Adam Smith, who showed that noise calibrated to sensitivity gives a provable guarantee. The version with a small failure probability δ\delta followed in the same period, and Gaussian noise became a common choice for high-dimensional outputs. Dwork and Aaron Roth's 2014 monograph gives the calibration used in this lesson. In 2016 Abadi and colleagues showed how to train deep networks with Gaussian noise on clipped gradients, which turned the mechanism into a standard tool in machine learning.

Recap

  • The Gaussian mechanism adds normal noise to a query's true answer.
  • The noise width σ\sigma grows with the L2 Global Sensitivity and shrinks as ε\varepsilon grows.
  • δ\delta is a small allowance for rare failures, so the guarantee is approximate.
  • Clipping makes the sensitivity finite, and repeated releases add up their privacy cost.
  • Read next: Differential Privacy, which defines the guarantee these numbers are chosen to meet.

Check yourself

QuestionIn one sentence, what does the Gaussian mechanism add to a query's answer?Show answer

It adds independent normal noise with mean zero, whose standard deviation is set by the query's L2 global sensitivity and the privacy target.

QuestionWith Δ2f=1\Delta_2 f = 1 and δ=10−5\delta = 10^{-5}, the calibrated noise standard deviation is about 9.69 when ε=0.5\varepsilon = 0.5. What is it, approximately, when ε=0.25\varepsilon = 0.25?Show answer

Since σ\sigma is proportional to 1/ε1/\varepsilon, halving ε\varepsilon doubles σ\sigma. The answer is about 2×9.69=19.42 \times 9.69 = 19.4.

QuestionWhy does the Gaussian mechanism use the L2 sensitivity rather than the L1 sensitivity?Show answer

The calibration theorem for the Gaussian mechanism is stated in terms of the L2 size of the change in the answer. The L2 size is never larger than the L1 size, so calibrating to L1 would still be safe, but it would add more noise than needed.

QuestionA DP-SGD run clips each example's gradient to length 0.5 and uses a noise multiplier of 1.5. A colleague says the noise per coordinate should be 1.5. Is that right?Show answer

No. The noise standard deviation is the noise multiplier times the clip length, so it is 1.5×0.5=0.751.5 \times 0.5 = 0.75 per coordinate.

Sources