Skip to main content

PLD PMF/PLD transformations: subsampling amplification and infinity-mass scaling utilities

Project description

PLD_subsampling

Implements and evaluates privacy amplification by subsampling for Privacy Loss Distribution (PLD) probability mass functions (PMFs). Generates CDF plots and epsilon ratio plots comparing analytical ground truth, dp-accounting, and our direct subsampling implementation.

Package layout

  • PLD_subsampling/
    • PLD_subsampling_impl.py: Core subsampling primitives
      • stable_subsampling_loss: numerically stable loss mapping
      • exclusive_ccdf_from_pdf: CCDF helper (exclusive tail)
      • subsample_losses: transforms a PMF on a uniform loss grid
    • wrappers/dp_accounting_wrappers.py: Thin wrappers around dp-accounting (construct PLDs, amplify PLDs separately for remove/add), plus PMF/PLD utilities
      • amplify_pld_separate_directions(base_pld, sampling_prob) -> PrivacyLossDistribution: returns a PLD with amplified remove/add PMFs
      • scale_pmf_infinity_mass(pmf, delta) -> PMF: increases the infinity mass by delta and scales all finite probabilities by (1-β-δ)/(1-β) preserving PMF type (dense/sparse)
      • scale_pld_infinity_mass(pld, delta) -> PrivacyLossDistribution: applies the same infinity-mass change to both directions of a PLD and returns a new PLD
    • testing/
      • analytic_Gaussian.py: Analytical PLD and epsilon(δ) formulas for Gaussian mechanism
      • test_utils.py: Experiment runners (run_experiment, run_multiple_experiments)
      • plot_utils.py: Plotting (CDF with focused x-range, epsilon ratio)
    • main.py: Runs experiments and saves figures to plots/

Quickstart

  1. Create a virtual environment and install dependencies
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
  1. Editable install for local development (optional)
pip install -e .
  1. Run experiments and generate plots
python -m PLD_subsampling.main

Figures are written to plots/ (treat this directory as build output).

Usage examples

Scale infinity mass on a PMF and a PLD (see PLD_subsampling/example.ipynb for a full demo):

from PLD_subsampling.wrappers.dp_accounting_wrappers import (
    scale_pmf_infinity_mass,
    scale_pld_infinity_mass,
)
from dp_accounting.pld import privacy_loss_distribution

# Build a fresh PLD
pld = privacy_loss_distribution.from_gaussian_mechanism(
    standard_deviation=1.0,
    sensitivity=1.0,
    value_discretization_interval=1e-4,
    sampling_prob=0.1,
    pessimistic_estimate=True,
)

# Scale a single PMF
pmf_scaled = scale_pmf_infinity_mass(pld._pmf_remove, delta=1e-4)

# Scale both directions of the PLD
pld_scaled = scale_pld_infinity_mass(pld, delta=1e-4)

Notes

  • CDF plots automatically focus the main x-axis on the transition region and add slight y-padding to show the 0 and 1 limits clearly.
  • Epsilon-ratio plots show method/GT vs analytical epsilon over log-scale epsilon.
  • All heavy computations use vectorized NumPy operations with careful numerical handling in tail regions.

Build a package

python -m pip install --upgrade build
python -m build

Artifacts will be created under dist/. To upload to PyPI/TestPyPI, use twine with an API token.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pld_subsampling-0.1.6.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pld_subsampling-0.1.6-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file pld_subsampling-0.1.6.tar.gz.

File metadata

  • Download URL: pld_subsampling-0.1.6.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pld_subsampling-0.1.6.tar.gz
Algorithm Hash digest
SHA256 464cea2c957921c5aab9bd8a8f2b29eaedc33831b90ecfa4fbd95afbaf06c941
MD5 c363f620fd888e6e77bbae61bbd6fe29
BLAKE2b-256 573472cb09513481f4face08b0ac354ded3554b5bed251e44752073197f424c5

See more details on using hashes here.

File details

Details for the file pld_subsampling-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for pld_subsampling-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d091638a7bd1d9bd1c74f251cdf208d0d1097f7822f99e12d4b42d3a2a13bec9
MD5 f39a1b0b33c343363f80aa9adaa0b498
BLAKE2b-256 cbc85fcdf44ebb2f1ee043984703363f73f3cbd55430e316143f646d31fd76e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page