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 primitivesstable_subsampling_loss: numerically stable loss mappingexclusive_ccdf_from_pdf: CCDF helper (exclusive tail)subsample_losses: transforms a PMF on a uniform loss grid
wrappers/dp_accounting_wrappers.py: Thin wrappers arounddp-accounting(construct PLDs, amplify PLDs separately for remove/add), plus PMF/PLD utilitiesamplify_pld_separate_directions(base_pld, sampling_prob) -> PrivacyLossDistribution: returns a PLD with amplified remove/add PMFsscale_pmf_infinity_mass(pmf, delta) -> PMF: increases the infinity mass bydeltaand 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 mechanismtest_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 toplots/
Quickstart
- 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
- Editable install for local development (optional)
pip install -e .
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pld_subsampling-0.1.4.tar.gz.
File metadata
- Download URL: pld_subsampling-0.1.4.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba047371f788daf6a501a7d1769ae5c08092d223f3ac1b619954c5d6c0ca6235
|
|
| MD5 |
347d6446e24f95b6e0303ea800c4c2fd
|
|
| BLAKE2b-256 |
b7fa62c41ffaaf5ac73911fc68b45abddd994475c7e9717b48c93c7693a7478b
|
File details
Details for the file pld_subsampling-0.1.4-py3-none-any.whl.
File metadata
- Download URL: pld_subsampling-0.1.4-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e576696dcce4a34e47f53b2a47dab7afbd8ba94a12223f34bba3209c33452f2
|
|
| MD5 |
7a729b5f4d6f617e0aef8f2b1fd8b202
|
|
| BLAKE2b-256 |
0e89ed91cf71b208412fc8a9d11e435e11605880040a9a3fad76410db9999b02
|