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.

double_sided_geometric_inverse_cmf_exact()

Return exact value of inverse cmf of 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) float#
double_sided_geometric_pmf(k: numpy.ndarray, alpha: float) numpy.ndarray
double_sided_geometric_pmf(k: int, alpha: numpy.ndarray) 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) float#
double_sided_geometric_cmf(k: numpy.ndarray, alpha: float) numpy.ndarray

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) numpy.ndarray

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.

double_sided_geometric_inverse_cmf_exact(p, alpha)#

Return exact value of inverse cmf of double-sided geometric distribution at p.

See double_sided_geometric_inverse_cmf() for more information.

Parameters
  • p (tmlt.core.utils.exact_number.ExactNumberInput) – The values to calculate the inverse cmf for.

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

Return type

tmlt.core.utils.exact_number.ExactNumber

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

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 in the paper.

Parameters
  • k – The value to evaluate the pmf at.

  • sigma_squared – The variance of the discrete gaussian distribution.

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

Returns the cmf for a discrete gaussian distribution at k.

See (1) for the probability mass function.

Parameters
  • k – The value to evaluate the cmf at.

  • sigma_squared – The variance of the discrete gaussian distribution.

discrete_gaussian_inverse_cmf(p: float, sigma_squared: float) int#
discrete_gaussian_inverse_cmf(p: numpy.ndarray, sigma_squared: float) numpy.ndarray
discrete_gaussian_inverse_cmf(p: tmlt.core.utils.arb.Arb, sigma_squared: tmlt.core.utils.arb.Arb) int

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

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

Parameters
  • p – The value to evaluate the inverse cmf at.

  • sigma_squared – The variance of the discrete gaussian distribution.