# distributions#

Probability functions for distributions commonly used in differential privacy.

## Functions#

 double_sided_geometric_pmf() Returns the pmf for a double-sided geometric distribution at k. double_sided_geometric_cmf() Returns the cmf for a double-sided geometric distribution at k. double_sided_geometric_cmf_exact() Returns exact value of the cmf for a double-sided geometric distribution at k. double_sided_geometric_inverse_cmf() Returns the inverse cmf of a double-sided geometric distribution at p. discrete_gaussian_pmf() Returns the pmf for a discrete gaussian distribution at k. discrete_gaussian_cmf() Returns the cmf for a discrete gaussian distribution at k. discrete_gaussian_inverse_cmf() Returns the inverse cmf for a discrete gaussian distribution at p.
double_sided_geometric_pmf(k: int, alpha: float) #
double_sided_geometric_pmf(k: numpy.ndarray, alpha: float)
double_sided_geometric_pmf(k: int, alpha: numpy.ndarray)

Returns the pmf for a double-sided geometric distribution at k.

For $$k \in \mathbb{Z}$$

$f(k)= \frac {e^{1 / \alpha} - 1} {e^{1 / \alpha} + 1} \cdot e^{\frac{-\mid k \mid}{\alpha}}$

A double sided geometric distribution is the difference between two geometric distributions (It can be sampled by sampling two values from a geometric distribution, and taking their difference).

See section 4.1 in [BV18] or scipy.stats.geom for more information (Note that the parameter $$p$$ used in scipy.stats.geom is related to $$\alpha$$ through $$p = 1 - e^{-1 / \alpha}$$).

Parameters
• k – The values to calculate the pmf for.

• alpha – The scale of the geometric distribution.

double_sided_geometric_cmf(k: int, alpha: float) #
double_sided_geometric_cmf(k: numpy.ndarray, alpha: float)

Returns the cmf for a double-sided geometric distribution at k.

For $$k \in \mathbb{Z}$$

$\begin{split}F(k) = \begin{cases} \frac{e^{1 / \alpha}}{e^{1 / \alpha} + 1} \cdot e^\frac{k}{\alpha} & \text{if k} \le 0 \\ 1 - \frac{1}{e^{1 / \alpha} + 1}\cdot e^{\frac{-k}{\alpha}} & \text{otherwise} \\ \end{cases}\end{split}$

See double_sided_geometric_pmf() for more information.

Parameters
• k – The values to calculate the pmf for.

• alpha – The scale of the geometric distribution.

double_sided_geometric_cmf_exact(k, alpha)#

Returns exact value of the cmf for a double-sided geometric distribution at k.

See double_sided_geometric_cmf() for more information.

Parameters
• k (tmlt.core.utils.exact_number.ExactNumberInput) – The values to calculate the pmf for.

• alpha (tmlt.core.utils.exact_number.ExactNumberInput) – The scale of the geometric distribution.

Return type

tmlt.core.utils.exact_number.ExactNumber

double_sided_geometric_inverse_cmf(p: float, alpha: float) int#
double_sided_geometric_inverse_cmf(p: numpy.ndarray, alpha: float)

Returns the inverse cmf of a double-sided geometric distribution at p.

In other words, it returns the smallest k s.t. CMF(k) >= p.

For $$p \in [0, 1]$$

$\begin{split}F(k) = \begin{cases} \alpha\ln(p\cdot\frac{e^{\frac{1}{\alpha}} + 1}{e^{\frac{1}{\alpha}}}) & \text{if p} \le 0.5 \\ -\alpha\ln((e^{\frac{1}{\alpha}} + 1)(1 - p)) & \text{otherwise} \\ \end{cases}\end{split}$

See double_sided_geometric_pmf() for more information.

discrete_gaussian_pmf(k: int, sigma_squared: float) #
discrete_gaussian_pmf(k: numpy.ndarray, sigma_squared: float)

Returns the pmf for a discrete gaussian distribution at k.

For $$k \in \mathbb{Z}$$

(1)#$f(k) = \frac {e^{-k^2/2\sigma^2}} { \sum_{n\in \mathbb{Z}} e^{-n^2/2\sigma^2} }$

See [CKS20] for more information. The formula above is based on Definition 1.

The implementation also referenced the paper’s implementation, which can be found at https://github.com/IBM/discrete-gaussian-differential-privacy.

discrete_gaussian_cmf(k: int, sigma_squared: float) #
discrete_gaussian_cmf(k: numpy.ndarray, sigma_squared: float)

Returns the cmf for a discrete gaussian distribution at k.

See (1) for the probability mass function.

discrete_gaussian_inverse_cmf(p: float, sigma_squared: float) int#
discrete_gaussian_inverse_cmf(p: numpy.ndarray, sigma_squared: float)

Returns the inverse cmf for a discrete gaussian distribution at p.

In other words, it returns the smallest k s.t. CMF(k) >= p.

This is not terribly performant. Don’t use it in places where it’s going to get called a lot.