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.3.tar.gz (13.5 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.3-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pld_subsampling-0.1.3.tar.gz
  • Upload date:
  • Size: 13.5 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.3.tar.gz
Algorithm Hash digest
SHA256 12dc506fbecd7ebe1ecbdcc7d684a5ce4ad178e765221ea1d90e41f02c6dba7d
MD5 827c3f567d517e9d803e0e214c7a047e
BLAKE2b-256 190119bb39ec2d4b501c4040bcc280ad02cd307a1c002fe30f97f15a8cb0e71f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pld_subsampling-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 55b9d761083bfa443b55dfa9ff64baa0be0a079597f02a5eae62a8cea3c1af77
MD5 a46575f4805aeba4beabaab5b3ef5968
BLAKE2b-256 b1cc62746fb56925785f1f3356adfd6b76a91fbf941106a7af8623c3a2c17f8a

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