Skip to content

Mean Estimation — API Reference

Auto-generated from the source docstrings. For the problem formulation and a usage example, see the Mean Estimation task page.

Types

dp_testing_platform.tasks.mean_estimation.types

MeanEstimationMetadata dataclass

Metadata for mean estimation.

Attributes:

Name Type Description
dim int

Dimension of the data vectors.

n_samples int

Number of samples in the dataset.

domain Domain | None

Domain constraint for the data. If None, data is unbounded.

MeanEstimationInput dataclass

Input for mean estimation.

Attributes:

Name Type Description
X Array2D

Data matrix, shape (n_samples, dim).

MeanEstimationOutput dataclass

Output for mean estimation.

Attributes:

Name Type Description
mean_est Array1D

Estimated mean vector, shape (dim,).

Algorithms

dp_testing_platform.tasks.mean_estimation.algorithms.sample_mean

SampleMean

Bases: BaseAlgorithm

Non-private sample mean (baseline).

Computes the arithmetic mean of each coordinate. No privacy guarantees. Standard/textbook estimator; not a DP mechanism and has no single canonical paper.

Reference

Non-private baseline; no DP source paper.

dp_testing_platform.tasks.mean_estimation.algorithms.gaussian_mech

GaussianMechanismMeanEstimation

Bases: BaseAlgorithm

Gaussian mechanism for mean estimation.

Adds Gaussian noise calibrated to the L2 sensitivity of the mean and satisfies (eps, delta)-DP at every budget.

The noise scale is the exact minimal sigma from the analytic Gaussian mechanism (Balle & Wang 2018, "Improving the Gaussian Mechanism for Differential Privacy", arXiv:1805.06530, Theorem 8 / Algorithm 1), valid for all eps > 0 — unlike the classical sqrt(2 ln(1.25/delta))/eps constant, whose proof holds only for eps < 1.

Requires a bounded domain in metadata.

Reference

Analytic Gaussian mechanism calibration: Balle & Wang, "Improving the Gaussian Mechanism for Differential Privacy: Analytical Calibration and Optimal Denoising", ICML 2018. https://arxiv.org/abs/1805.06530

dp_testing_platform.tasks.mean_estimation.algorithms.coinpress

CoinPressMeanEstimation

Bases: BaseAlgorithm

CoinPress algorithm for mean estimation (Biswas et al., NeurIPS 2020).

Implements CoinPress (Biswas, Dong, Kamath & Ullman, "CoinPress: Practical Private Mean and Covariance Estimation", NeurIPS 2020, arXiv:2006.06618): iteratively refines the mean estimate with progressively smaller radius. Satisfies concentrated DP, converted from (eps, delta)-DP.

Requires a bounded domain in metadata.

Reference

Biswas, Dong, Kamath & Ullman, "CoinPress: Practical Private Mean and Covariance Estimation", NeurIPS 2020. https://arxiv.org/abs/2006.06618

Hyperparameters

num_iters: Number of refinement iterations. Default: 1. failure_prob: Probability of estimation failure. Default: 0.01.

Lifted algorithms

M-estimation algorithms presented as native mean-estimation algorithms (the squared-error loss whose minimizer is the sample mean).

dp_testing_platform.tasks.mean_estimation.algorithms.lifted

M-estimation algorithms lifted onto the mean-estimation task.

Each class presents an m_estimation algorithm as a native mean_estimation algorithm. The child->parent map fixes the squared-error loss whose minimizer is the sample mean: the per-row data vector is passed through unchanged and the fitted M-estimation parameter vector is returned as the mean estimate. lift_input is per-row (row i maps to row i), so the inner algorithm's (eps, delta)-DP guarantee transfers verbatim.

Instance generators

dp_testing_platform.tasks.mean_estimation.instance_generators.simple_gaussian

SimpleGaussian

Bases: InstanceGenerator

Gaussian instance generator for mean estimation.

Generates X ~ N(mu, I) where mu is a random vector with given norm.

The metadata carries a public parameter-derived BoxDomain: every coordinate of mu is bounded by mean_radius (mu has L2 norm mean_radius) and the unit-variance noise by a fixed slack, giving per-coordinate bounds ±(mean_radius + 6). The bounds depend only on the generator's public parameters — never on the realized data — so publishing them leaks nothing. Samples fall outside the box only with negligible probability; domain-requiring algorithms project/clip onto the claimed domain, which keeps their DP guarantee regardless.

dp_testing_platform.tasks.mean_estimation.instance_generators.clipped_normal

ClippedNormal

Bases: InstanceGenerator

Clipped Gaussian instance generator for mean estimation.

Generates X ~ N(mu, I) clipped to L2 ball. Provides bounded domain metadata.

dp_testing_platform.tasks.mean_estimation.instance_generators.clipped_laplacian

ClippedLaplacian

Bases: InstanceGenerator

Clipped Laplacian instance generator for mean estimation.

Generates X ~ Laplace(mu, 1) clipped to L2 ball. Provides bounded domain metadata.

Metrics

dp_testing_platform.tasks.mean_estimation.metrics

Metric registry for mean_estimation task.

l2_error

l2_error(output: MeanEstimationOutput, reference: Array1D) -> float

L2 error between estimated mean and reference.

dp_noisy_error_norm

dp_noisy_error_norm(output: MeanEstimationOutput, evaluation_metadata: MeanEstimationMetadata, evaluation_input: MeanEstimationInput, budget: DPBudget, seed: int) -> float

Noisy L2 distance from the estimate to the evaluation sample mean.

A selection cost — lower is better, matching the argmin the DP selection tuners take (0 when the estimate equals the evaluation sample mean, growing with estimation error). Changing one evaluation record moves mean(X), hence its distance to the already-released mean_est, by at most L2diam/n, so dist + Laplace(0, L2diam/(n*eps)) is eps-DP, where L2diam is the evaluation domain's L2 diameter. Non-pure allowances are spent conservatively through the pure-DP accounting route.

Raises:

Type Description
ValueError

If evaluation_metadata.domain is None (no L2 diameter is available to calibrate the noise).