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.5.tar.gz (14.3 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.5-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pld_subsampling-0.1.5.tar.gz
  • Upload date:
  • Size: 14.3 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.5.tar.gz
Algorithm Hash digest
SHA256 6f04c51df1217140ce770f43cf7e0b5725a12468809fac9ba2348670ccc8c2e0
MD5 37a8da919c4715b34a5b05d99c3aada6
BLAKE2b-256 49fd48b557536b8bb0bf188cf71a32c212e43fbb1dadf9f8a66b6b8c7bf80507

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pld_subsampling-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9882eb08e556bee329c54eb962c173f495019db96170dabb458235cfcd70790d
MD5 8e33c1d6231f19ab725a4f8650f966c3
BLAKE2b-256 43c54355d3f65c646f57e9965672e35dff05aacf939e302ee8f3932e060e2915

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