Accuracy#

(See also opendp.accuracy in the API reference.)

The library contains utilities to estimate accuracy at a given noise scale and statistical significance level or derive the necessary noise scale to meet a given target accuracy and statistical significance level.

Note

This confidence interval is specifically for the input to the noise addition mechanism. The library currently does not compensate for the bias introduced from clipping or other preprocessing ([KMRS+23] shows that this is somewhat unavoidable). In the Theory section we have a notebook demonstrating this limitation.

The noise distribution may be either Laplace or Gaussian.

Laplacian:
Applies to any L1 noise addition mechanism.
Gaussian:
Applies to any L2 noise addition mechanism.

The library provides the following functions for converting between noise scale and accuracy:

To demonstrate, the following snippet finds the necessary gaussian scale such that the input to make_gaussian(input_domain, input_metric, scale=1.) differs from the release by no more than 2 with 95% confidence.

>>> import opendp.prelude as dp
>>> confidence = 95
>>> dp.accuracy_to_gaussian_scale(accuracy=2., alpha=1. - confidence / 100)
1.020426913849308

You can generally plug the distribution (Laplace or Gaussian), scale, accuracy and alpha into the following statement to interpret these functions:

f"When the {distribution} scale is {scale}, "
f"the DP estimate differs from the true value by no more than {accuracy} "
f"at a statistical significance level alpha of {alpha}, "
f"or with (1 - {alpha})100% = {(1 - alpha) * 100}% confidence."