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.
Metadata
Release files for PLD-subsampling 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pld_subsampling-0.1.6.tar.gz | 14.4 kB | Without provenance | Details for pld_subsampling-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pld_subsampling-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for pld_subsampling-0.1.6-py3-none-any.whl |
Total release size: 29.8 kB
Release files / pld_subsampling-0.1.6.tar.gz
| Download URL | pld_subsampling-0.1.6.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
464cea2c957921c5aab9bd8a8f2b29eaedc33831b90ecfa4fbd95afbaf06c941
|
|
BLAKE2b-256 checksum How to use checksums |
573472cb09513481f4face08b0ac354ded3554b5bed251e44752073197f424c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / pld_subsampling-0.1.6-py3-none-any.whl
| Download URL | pld_subsampling-0.1.6-py3-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d091638a7bd1d9bd1c74f251cdf208d0d1097f7822f99e12d4b42d3a2a13bec9
|
|
BLAKE2b-256 checksum How to use checksums |
cbc85fcdf44ebb2f1ee043984703363f73f3cbd55430e316143f646d31fd76e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for PLD-subsampling 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.