prdp#

Floating-point safe utility functions for per-record diffential privacy.

Functions#

fourth_root_transformation_mechanism()

Fourth root transformation mechanism.

square_root_transformation_mechanism()

Square root transformation mechanism.

log_transformation_mechanism()

Log transformation mechanism.

square_root_gaussian_inverse_cdf()

Inverse CDF for a special case of the generalized Gaussian distribution.

square_root_gaussian_mechanism()

Samples a float from the generalized Gaussian distribution.

exponential_polylogarithmic_inverse_cdf()

Inverse CDF for the exponential polylogarithmic distribution.

exponential_polylogarithmic_mechanism()

Samples a float from the exponential polylogarithmic distribution.

fourth_root_transformation_mechanism(x, offset, sigma)#

Fourth root transformation mechanism.

Parameters
Return type

float

square_root_transformation_mechanism(x, offset, sigma)#

Square root transformation mechanism.

Parameters
Return type

float

log_transformation_mechanism(x, offset, sigma)#

Log transformation mechanism.

Parameters
Return type

float

square_root_gaussian_inverse_cdf(x, sigma, prec)#

Inverse CDF for a special case of the generalized Gaussian distribution.

In particular, this function returns the inverse CDF of the generalized Gaussian distribution when the shape parameter is 1/2:

\[\begin{split}\begin{equation} \text{CDF}^{-1}(x) = \begin{cases} 0 & x = \frac{1}{2} \\ \sigma\left[-W\left(\frac{2x-2}{e}\right)-1\right]^2 & x > \frac{1}{2} \\ -\sigma\left[-W\left(\frac{-2x}{e}\right)-1\right]^2 & x < \frac{1}{2} \end{cases} \end{equation}\end{split}\]
Parameters
Return type

tmlt.core.utils.arb.Arb

square_root_gaussian_mechanism(sigma)#

Samples a float from the generalized Gaussian distribution.

Parameters

sigma (float) –

Return type

float

exponential_polylogarithmic_inverse_cdf(x, d, a, sigma, prec)#

Inverse CDF for the exponential polylogarithmic distribution.

In particular, this function computes the inverse CDF as defined below:

\[\begin{split}y = \begin{cases} - \sigma \exp \left[\left([2d]^{-1/2}\Phi^{-1}\left[\left(\left[1-\Phi\left(\frac{\ln(a)-(2d)^{-1}}{(2d)^{-1/2}}\right)\right][1- 2x] \right) + \Phi\left(\frac{\ln(a)-(2d)^{-1}}{(2d)^{-1/2}}\right) \right]\right) + (2d)^{-1} \right] + \sigma a& x <\frac{1}{2} \\ \sigma \exp \left[\left([2d]^{-1/2}\Phi^{-1}\left[\left(\left[1-\Phi\left(\frac{\ln(a)-(2d)^{-1}}{(2d)^{-1/2}}\right)\right][2x - 1]\right) + \Phi\left(\frac{\ln(a)-(2d)^{-1}}{(2d)^{-1/2}}\right) \right]\right) + (2d)^{-1}\right] - \sigma a& x >\frac{1}{2} \\ 0 & x = \frac{1}{2} \end{cases}\end{split}\]
Parameters
Return type

tmlt.core.utils.arb.Arb

exponential_polylogarithmic_mechanism(d, a, sigma, step_size=63)#

Samples a float from the exponential polylogarithmic distribution.

Parameters
Return type

float