jax_privacy.experimental.monte_carlo.sample_generation.generate_sample

jax_privacy.experimental.monte_carlo.sample_generation.generate_sample#

jax_privacy.experimental.monte_carlo.sample_generation.generate_sample(strategy, noise_multiplier, c_col, seed=None, positive_sample=True, num_samples=1, dataset_size=None, mode_scale=None)[source]#

Generates a sample from the dominating pair for amplified DP-BandMF.

TODO: Explore benefits of Jax implementation.

Parameters:
  • strategy (BallsInBinsSampling | BMinSepSampling | CyclicPoissonSampling) – The batch selection strategy to use. Currently, BallsInBinsSampling, CyclicPoissonSampling (using INDEPENDENT partition type), and BMinSepSampling are supported. See Choquette-Choo et al. (2024) and Dong and Ganesh (2026) for technical details.

  • noise_multiplier (float) – The noise multiplier of DP-MF. This is multiplied by the clip norm, not accounting for the norm of c_col.

  • c_col (ndarray) – The non-zero entries in the first column of C. Should be non-negative and 1D.

  • seed (int | Generator | None) – The rng or seed to use for sampling.

  • positive_sample (bool) – If True, we sample from the distribution in the dominating pair corresponding to the case where the sensitive example is included. Otherwise, we sample from the other case in the dominating pair, where the sensitive example is not included. Ignored if mode_scale is not None.

  • num_samples (int) – The number of samples to generate. The default is 1, but it is typically much more efficient to generate multiple samples in a single call to benefit from vectorization.

  • dataset_size (int | None) – The size of the dataset. Should only be set if accounting for the strategy supports truncation, and strategy.truncated_batch_size is not None.

  • mode_scale (float | None) – If None, we sample from the dominating pair according to positive_sample. Otherwise, the modes of the positive mixture are multiplied by mode_scale before noise is added, which samples from a stretched mixture that is useful as a proposal distribution for importance sampling (0 and 1 recover the dominating pair). Only supported for balls-in-bins sampling.

Return type:

ndarray | tuple[ndarray, ndarray]

Returns:

Sample(s) from the dominating PLD for DP-BandMF using balls-in-bins sampling. The output is 2D with dimension (strategy.iterations, num_samples). Potentially also returns a second array containing auxiliary information needed to evaluate the privacy loss.