Skip to main content

Fourier Accountant

Python code for computing tight DP-guarantees for the subsampled Gaussian mechanism.

The method is described in:

Antti Koskela, Joonas Jälkö, Antti Honkela:
Computing Tight Differential Privacy Guarantees Using FFT
International Conference on Artificial Intelligence and Statistics (2020)

API and Usage

  • get_delta_R(target_eps, sigma, q, ncomp, nx, L) Computes the DP delta for the remove/add neighbouring relation of datasets.
  • get_delta_S(target_eps, sigma, q, ncomp, nx, L) Computes the DP delta for the substitute neighbouring relation of datasets.
  • get_epsilon_R(target_delta, sigma, q, ncomp, nx, L) Computes the DP epsilon for the remove/add neighbouring relation of datasets.
  • get_epsilon_S(target_delta, sigma, q, ncomp, nx, L) Computes the DP epsilon for the substitute neighbouring relation of datasets.

Parameters

  • target_eps (float): Target epsilon to compute delta for
  • target_delta (float): Target delta to compute epsilon for
  • sigma (float or np.ndarray): Privacy noise sigma values
  • q (float or np.ndarray): Subsampling ratios, i.e., how large are batches relative to the dataset
  • ncomp (int or np.ndarray with integer type): Number of compositions, i.e., how many subsequent batch operations are queried
  • nx (int): Number of discretiation points
  • L (float): Limit for the approximation of the privacy loss distribution integral

For parameters sigma, q and ncomp either a single scalar or an array can be passed. If a scalar is passed, the value will be re-interpreted as an array of length 1. Each function then computes the privacy values (delta or epsilon) resulting from a composition of subsampled Gaussian mechanism with following parameters:

  • ncomp[0] times noise level sigma[0] and subsamplign rate q[0]
  • ncomp[1] times noise level sigma[1] and subsamplign rate q[1]
  • etc. for a total of np.sum(ncomp) operations.

An exception is raised if sigma, q and ncomp are found to not be of the same length.

Usage Notes

Note that the functions rely on numerical approximations, which are influenced by choice of parameters nx and L. Increasing L roughly increases the range over which the integral of the privacy loss distribution is approximated. L must be chosen large enough to cover the computed epsilon, otherwise a ValueError is raised (in get_epsilon_*). nx is the number of evaluation points in $[-L,L]$.

Usage Example

import fourier_accountant

ncomp = 1000  # number of compositions of DP queries over minibatches
q     = 0.01  # subsampling ratio of minibatch
sigma = 4.0   # noise level for each query

# computing delta for given epsilon for remove/add neighbouring relation
delta = fourier_accountant.get_delta_R(target_eps=1.0, sigma=sigma, q=q, ncomp=ncomp)
print(delta)
# 4.243484012034273e-06

# computing epsilon for given delta for substitute neighbouring relation
eps = fourier_accountant.get_epsilon_S(target_delta=1e-5, sigma=sigma, q=q, ncomp=ncomp)
print(eps)
# 1.9931200626285734

# computing delta for given epsilon for remove/add neighbouring relation
# with varying parameters
ncomp = np.array([500, 500])
q     = np.array([0.01, 0.01])
sigma = np.array([2.0, 1.0])
delta = fourier_accountant.get_delta_R(target_eps=1.0, sigma=sigma, q=q, ncomp=ncomp)
print(delta)
# 0.0003151995621652058

Release files for fourier-accountant 0.12.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fourier-accountant 0.12.11
File Size Uploaded
fourier_accountant-0.12.11.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fourier-accountant 0.12.11
File Interpreter ABI Platform
fourier_accountant-0.12.11-py3-none-any.whl Python 3 none any Details

Total release size: 30.2 kB

Release files / fourier_accountant-0.12.11.tar.gz

Download URL fourier_accountant-0.12.11.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c06af809d0b3009c1119634448f41e487e92aeccf4b2f78b4aa13daf5d1dbb5a
BLAKE2b-256 checksum
How to use checksums
fd3d0269e824531be6ddb75e8c70fc9ce631a89039b6f59acba028ff7c5e2031
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.6

Release files / fourier_accountant-0.12.11-py3-none-any.whl

Download URL fourier_accountant-0.12.11-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a77b1991db37ef86ffc0dac6dfe0f1e15d1c3881f578c33d6507d41c770e549c
BLAKE2b-256 checksum
How to use checksums
abb5fc80b5e0901ff8aaa8eae7830bc5d922a25c418eb831139591458537542a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.6

Release history Release notifications | RSS feed

This release

0.12.11 This release

2 release files

0.12.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page