dit.rate_distortion

Various implementations of rate-distortion theory.

Classes

DeterministicInformationBottleneck

The deterministic information bottleneck objective.

ExtensionPoint

A point of the extension profile.

ExtensionProfile

The extension profile of a pair and its distinguished points.

GeneralizedInformationBottleneck

The generalized information bottleneck family.

GrayWynerCurve

Compute the common-rate vs total-private-rate trade-off curve.

GrayWynerNetwork

The generalized Gray-Wyner network for a source distribution.

GrayWynerOptimizer

Minimize a weighted sum of Gray-Wyner rates over the common auxiliary variable W (and reconstruction test channels for lossy decoders).

GrayWynerPoint

IBCurve

Compute an information bottleneck curve.

InformationBottleneck

Base optimizer for information bottleneck type calculations.

InformationBottleneckDivergence

A generalized information bottleneck which uses a distortion equal to D( p(Y|x) || q(Y|t) ) for an arbitrary divergence measure D.

InformationBottleneckRate

The information bottleneck at a fixed rate [TPB00],

MutualInformationPoint

A point of the mutual information region of [LEG18a].

PFCurve

Compute a privacy funnel curve [MSFMedard14]: the least leakage I[S : T | Z] of a release T of X as a function of its utility I[X : T | Z].

PrivacyFunnel

The privacy funnel Lagrangian [MSFMedard14],

PrivacyFunnelRate

The privacy funnel [MSFMedard14],

PrivacyFunnelResult

The result of a finite-alphabet privacy funnel optimization.

RDCurve

Compute a rate-distortion curve.

ShapeFunction

The shape function of a tuple of random variables.

TensionPoint

A point of the region of tension.

Functions

admits_perfect_privacy

Determine whether X can be released with non-zero utility and zero leakage about S.

asymmetric_private_interaction_information

Compute the asymmetric private interaction information.

excess_functional_information

The excess functional information [LEG18b]

extension_to_rates

Convert extension-profile coordinates back to a Gray-Wyner rate point.

greedy_privacy_funnel

Greedily merge released symbols for the privacy funnel [MSFMedard14].

hamming_matrix

Construct a k x k Hamming distortion matrix.

information_bottleneck_rate

Compute the information bottleneck at a fixed rate: the largest relevance I[Y : T | Z] of a representation T of X with complexity I[X : T | Z] <= rate [TPB00].

korner_graph_entropy

Körner's graph entropy [Korner73] of the characteristic graph of \(X\) (two values are adjacent when some \(y\) is compatible with both),

lossy_wyner_common_information

The lossy Wyner common information C(D_1, ..., D_n).

maximal_interaction_information

Compute the maximal interaction information.

mutual_information_to_rates

Convert mutual information coordinates back to a Gray-Wyner rate point.

perfect_privacy_utility

Compute the maximal utility at perfect privacy,

privacy_funnel

Compute a point on the privacy funnel by minimizing I[S : T | Z] - beta I[X : T | Z] [MSFMedard14].

privacy_funnel_rate

Compute the privacy funnel, the least leakage I[S : T | Z] of a release T of X with utility I[X : T | Z] >= rate [MSFMedard14].

rates_to_extension

Convert a Gray-Wyner rate point to extension-profile coordinates.

rates_to_mutual_information

Convert a Gray-Wyner rate point to mutual information coordinates.

rates_to_tension

Convert a Gray-Wyner rate point to tension coordinates.

symmetric_private_interaction_information

Compute the symmetric private interaction information.

tension_to_rates

Convert tension coordinates back to a Gray-Wyner rate point.

Reference

class DeterministicInformationBottleneck(dist, beta, alpha=0.0, rvs=None, crvs=None, bound=None)[source]

Bases: GeneralizedInformationBottleneck

The deterministic information bottleneck objective.

This is the alpha=0 endpoint of the generalized information bottleneck, using \(H(T | Z)\) as the compression term.

class ExtensionPoint(conditional_entropies, residual)

Bases: tuple

A point of the extension profile.

conditional_entropies

The conditional entropies H[X_i | W].

Type:

tuple of float

residual

The residual dependence T[X_{0:n} | W].

Type:

float

class ExtensionProfile(dist, rvs=None, bound=None, rng=None)[source]

Bases: object

The extension profile of a pair and its distinguished points.

The lower boundary is sampled over every downward direction \((\alpha, \beta, -1)\), written as \(\alpha + i\beta = r e^{i\theta}\); for each \(\theta\) the optimum is continued along \(r\) (from \(r \to 0\), the rim of the bottom face \(I[X:Y|W] = 0\), to \(r \to \infty\), the silhouette), then every grid point is re-solved from its neighbours until none improves. Points with negligible \(I[X:Y|W]\) are snapped to the bottom face. The upper boundary is sampled over upward directions. All of these are attained points, so their hull is an inner approximation of the body.

Parameters:
  • dist (Distribution) – The distribution of interest.

  • rvs (list of lists, None) – The two variables [X, Y]. If None, the two variables of dist.

  • bound (int, None) – Cardinality of the auxiliary W in the boundary optimizations. If None, min(support + 2, 8).

  • rng (int, numpy.random.Generator, None) – Seed or generator for the optimizers’ random starts.

support_point(direction, starts=8)[source]

A point of the extension profile maximizing direction . (x, y, z).

Parameters:
  • direction (array-like) – The direction (any length; it need not be normalized).

  • starts (int) – Number of random starts.

Returns:

point – The supporting point (H[X|W], H[Y|W], I[X:Y|W]).

Return type:

np.ndarray

lower_boundary(num_theta=48, num_radii=33, r_min=1e-05, r_max=1000.0, max_passes=6)[source]

Sample the lower (downward-facing) boundary.

Parameters:
  • num_theta (int) – Number of angles round the circle.

  • num_radii (int) – Number of radii, geometrically spaced in [r_min, r_max].

  • r_min (float) – The radial range; small radii resolve the bottom-face rim.

  • r_max (float) – The radial range; small radii resolve the bottom-face rim.

  • max_passes (int) – Maximum neighbour-relaxation passes.

Returns:

points – Shape (num_theta, num_radii, 3).

Return type:

np.ndarray

upper_boundary(num=300, starts=4)[source]

Sample the upper (upward-facing) boundary in num directions.

Returns:

points – Shape (m, 3).

Return type:

np.ndarray

wyner(niter=None)[source]

The Wyner point [Wyn75b], the realizer of the Wyner common information.

exact(niter=None)[source]

The point of a realizer of the exact common information [KLEG14].

relaxed_wyner(num=25)[source]

The relaxed-Wyner curve [GS19]: the diagonal alpha = beta in (0, 1/2].

beta_common(betas=None, niter=None)[source]

Realizer points of the beta-common information [YLC17] for each beta.

information_bottleneck(num=60)[source]

Both information-bottleneck arcs [LEG18a, TPB00]: the lower arcs of the zero-leakage faces x - z = H[X|Y] (U generated from Y) and its mirror, from W = const to the Kamath point.

Returns:

arcs – [X -> Y, Y -> X].

Return type:

list of np.ndarray

privacy_funnel(num=60)[source]

Both privacy-funnel arcs [LEG18a, MSFMedard14]: the upper arcs of the zero-leakage faces, from W = Y (or X) to perfect privacy.

Returns:

arcs – [X -> Y, Y -> X].

Return type:

list of np.ndarray

public_channel_synthesis(lower, num=45)[source]

The communication rate for distributed channel synthesis over a public channel with common-randomness rate t [Cuf13],

\[C_{pub}(t, X \to Y) = \min_{X - U - Y,\ I[XY:U] \le t} I[X:U].\]

The public message must look independent of the synthesized pair, so the common randomness must cover all of \(I[XY:U]\): the curve starts at the Wyner point, t equal to the Wyner common information, and reaches C = I[X:Y] at U = Y, where t = H[Y]. In the mutual information region it is the lower edge of the bottom face’s projection onto the \((I[X:U], I[XY:U])\) plane.

Parameters:
  • lower (np.ndarray) – Lower-boundary points (from lower_boundary); their z = 0 subset gives the rim.

  • num (int) – Number of values of t.

Returns:

  • ts (np.ndarray) – The common-randomness rates.

  • curves (list of (np.ndarray, np.ndarray)) – [(values, points) for X -> Y, (values, points) for Y -> X].

channel_synthesis(lower, num=45)[source]

The communication rate for distributed channel synthesis with common-randomness rate t [Cuf13, LEG18a],

\[C(t, X \to Y) = \min_{X - U - Y} \max\{I[X:U],\ I[XY:U] - t\},\]

a minimization over the bottom face of the extension profile. Its optimal U runs along the bottom-face rim from the Wyner point (t = 0) towards the Kamath point, where C(t) = I[X:Y]. This interpolates the rim for plotting; for the rate at a single t, optimized directly, use dit.multivariate.channel_synthesis_rate.

In region-of-tension coordinates, \(I[X:U] = I[X:Y] + \tau_2\) and the common randomness used at a corner point is \(I[Y:U|X] = \tau_1\), so \(C(t) = I[X:Y] + \min_{\tau_3 = 0} \{\tau_2 + (\tau_1 - t)^+\}\). The decoder needs local randomness \(H[Y|U]\), the extension-profile y coordinate.

Parameters:
  • lower (np.ndarray) – Lower-boundary points (from lower_boundary); their z = 0 subset gives the rim.

  • num (int) – Number of values of t, from 0 to a little past the rate at which C(t) = I[X:Y] (the necessary conditional entropy).

Returns:

  • ts (np.ndarray) – The common-randomness rates.

  • curves (list of (np.ndarray, np.ndarray)) – [(values, points) for X -> Y, (values, points) for Y -> X].

compute(lower=None, upper=None, curves=None, slow=True, niter=None)[source]

Compute the boundary and every distinguished point.

Parameters:
  • lower (dict, None) – Keyword arguments for lower_boundary, upper_boundary and the arc methods (num).

  • upper (dict, None) – Keyword arguments for lower_boundary, upper_boundary and the arc methods (num).

  • curves (dict, None) – Keyword arguments for lower_boundary, upper_boundary and the arc methods (num).

  • slow (bool) – Whether to run the non-convex realizer optimizations (Wyner, exact, beta).

  • niter (int, None) – Basin hops for those optimizations.

Returns:

features – Everything plot_extension_profile draws.

Return type:

dict

plot(features=None, **kwargs)[source]

Draw the extension profile with Plotly. See plot_extension_profile.

Parameters:
  • features (dict, None) – Output of compute. If None, it is computed with defaults.

  • kwargs (dict) – Passed to plot_extension_profile.

Returns:

fig – The interactive figure.

Return type:

plotly.graph_objects.Figure

plot_mutual_information_region(features=None, **kwargs)[source]

Draw the mutual information region [LEG18a] with Plotly. See plot_mutual_information_region.

plot_tension_region(features=None, **kwargs)[source]

Draw the region of tension [PP14] with Plotly. See plot_tension_region.

class GeneralizedInformationBottleneck(dist, beta, alpha=1.0, rvs=None, crvs=None, bound=None)[source]

Bases: InformationBottleneck

The generalized information bottleneck family.

The parameter alpha interpolates between the standard information bottleneck (alpha=1) and the deterministic information bottleneck (alpha=0).

class GrayWynerCurve(dist, rvs=None, crvs=None, distortions=None, distortion_bounds=None, s_min=0.0, s_max=4.0, s_num=21, niter=None, maxiter=1000, bound=None)[source]

Bases: object

Compute the common-rate vs total-private-rate trade-off curve.

compute(niter=None, maxiter=1000)[source]

Sweep the private-rate weight and compute the trade-off curve.

Parameters:
  • niter (int, None) – Number of basin hops per point.

  • maxiter (int) – Inner optimizer iterations.

plot(downsample=5)[source]

Plot the trade-off curve.

Parameters:

downsample (int) – How frequently to place markers along the curve.

Returns:

fig – The resulting figure.

Return type:

plt.Figure

class GrayWynerNetwork(dist, rvs=None, crvs=None, distortions=None, distortion_bounds=None, bound=None)[source]

Bases: object

The generalized Gray-Wyner network for a source distribution.

Parameters:
  • dist (Distribution) – The source distribution.

  • rvs (list of lists, None) – The source groups X_1, ..., X_n. If None, each variable of dist is its own source.

  • crvs (list, None) – Variables to condition the network on. If None, none.

  • distortions (list, None) – Per-decoder distortion matrices, or None entries for lossless decoders. If None, every decoder is lossless.

  • distortion_bounds (list, None) – Per-decoder distortion budgets D_i. If None, all zero (lossless).

  • bound (int, None) – Optional cap on the cardinality of the common auxiliary W.

rate_point(lambdas, niter=None, maxiter=1000, polish=1e-06, rng=None, **kwargs)[source]

Compute the Gray-Wyner rate point supporting a weight vector.

Parameters:
  • lambdas (iterable of float) – The weights (lambda_0, lambda_1, ..., lambda_n).

  • niter (int, None) – Number of basin hops.

  • maxiter (int) – Inner optimizer iterations.

  • polish (float) – Polishing cutoff; if falsey, no polishing.

  • kwargs (dict) – Additional keyword arguments for GrayWynerOptimizer, such as allow_signed or rate_equalities.

Returns:

point – The supporting (common, private) rate point.

Return type:

GrayWynerPoint

region(num=20, niter=None, maxiter=1000, rng=None)[source]

Sample the lower boundary of the achievable rate region.

Weight vectors are drawn on the (n + 1)-simplex (the vertices, plus random Dirichlet samples) and the supporting rate point of each is computed.

Parameters:
  • num (int) – The number of random weight vectors to sample (in addition to the n + 1 simplex vertices).

  • niter (int, None) – Number of basin hops per point.

  • maxiter (int) – Inner optimizer iterations.

  • rng (int, np.random.Generator, None) – Seed for the random weight sampler.

Returns:

points – The sampled boundary points.

Return type:

list of GrayWynerPoint

tension_point(lambdas, **kwargs)[source]

Compute a point of the region of tension supporting a weight vector.

Parameters:
  • lambdas (iterable of float) – The Gray-Wyner weights (lambda_0, lambda_1, ..., lambda_n).

  • kwargs (dict) – Additional keyword arguments for rate_point().

Returns:

point – The supporting point, in tension coordinates.

Return type:

TensionPoint

tension_region(num=20, niter=None, maxiter=1000, rng=None)[source]

Sample the lower boundary of the region of tension.

The region proper is the increasing hull of the attainable tension points [PP14]; the points returned here are attainable ones on its lower boundary.

Parameters:
  • num (int) – The number of random weight vectors to sample, in addition to the n + 1 simplex vertices.

  • niter (int, None) – Number of basin hops per point.

  • maxiter (int) – Inner optimizer iterations.

  • rng (int, np.random.Generator, None) – Seed for the random weight sampler.

Returns:

points – The sampled boundary points.

Return type:

list of TensionPoint

extension_profile(num=20, niter=None, maxiter=1000, rng=None)[source]

Sample the lower boundary of the extension profile.

The extension profile [MR26a] records (H[X_i | W], ..., T[X_{0:n} | W]); for a pair this is the (H[X|W], H[Y|W], I[X:Y|W]) body of that reference.

Parameters:
  • num (int) – The number of random weight vectors to sample, in addition to the n + 1 simplex vertices.

  • niter (int, None) – Number of basin hops per point.

  • maxiter (int) – Inner optimizer iterations.

  • rng (int, np.random.Generator, None) – Seed for the random weight sampler.

Returns:

points – The sampled boundary points.

Return type:

list of ExtensionPoint

mutual_information_region(num=20, niter=None, maxiter=1000, rng=None)[source]

Sample the lower boundary of the mutual information region.

The mutual information region [LEG18a] records (I[X_i : W], ..., I[X_{0:n} : W]). Unlike the region of tension, which tensorizes exactly, this region is only superadditive.

Parameters:
  • num (int) – The number of random weight vectors to sample, in addition to the n + 1 simplex vertices.

  • niter (int, None) – Number of basin hops per point.

  • maxiter (int) – Inner optimizer iterations.

  • rng (int, np.random.Generator, None) – Seed for the random weight sampler.

Returns:

points – The sampled boundary points.

Return type:

list of MutualInformationPoint

tension_intercepts(niter=None, maxiter=1000)[source]

The axis intercepts of the region of tension.

These are the T_i of [PP14] (their equation 1): the smallest value each coordinate can take when every other coordinate is zero. They are constrained optima rather than supporting-hyperplane queries.

The residual intercept satisfies T_res = I[X:Y] - K[X:Y], which is the Gacs-Korner corollary of [PP14] (their Corollary 3.3); the source intercepts are the Wolf-Wullschleger monotones.

Parameters:
  • niter (int, None) – Number of basin hops per intercept.

  • maxiter (int) – Inner optimizer iterations.

Returns:

intercepts – Mapping from coordinate (source index, or 'residual') to the intercept value.

Return type:

dict

corner_points(niter=None, maxiter=1000)[source]

The named common-information operating points of the network.

For a lossless network the corners are the standard common informations, computed by delegating to their canonical implementations so the values stay consistent across dit. The returned values are the common-rate (R_0) coordinates of those operating points.

Parameters:
  • niter (int, None) – Number of basin hops (forwarded to the optimization-based measures).

  • maxiter (int) – Inner optimizer iterations (forwarded likewise).

Returns:

corners – A mapping from measure name to its R_0 value.

Return type:

dict

class GrayWynerOptimizer(dist, lambdas, rvs=None, crvs=None, distortions=None, distortion_bounds=None, markov=False, bound=None, allow_signed=False, rate_equalities=None)[source]

Bases: BaseAuxVarOptimizer

Minimize a weighted sum of Gray-Wyner rates over the common auxiliary variable W (and reconstruction test channels for lossy decoders).

compute_bound()[source]

Caratheodory-style cardinality bound on W.

The Fenchel-Eggleston strengthening of Caratheodory’s theorem gives |W| <= |X_1| ... |X_n| + 2: the joint pmf must be preserved (prod - 1 constraints) and the rate point itself contributes the remaining degrees of freedom. This is the bound used throughout the assisted-common-information literature [LEG18a, PP14].

Returns:

bound – The bound on the alphabet size of W.

Return type:

int

optimize(x0=None, niter=None, maxiter=None, polish=1e-06, callback=False, rng=None)[source]

Perform the optimization, including the deterministic probe seeds.

Parameters:
  • x0 (np.ndarray, None) – The vector to initialize the optimization with.

  • niter (int, None) – The number of basin hops to perform.

  • maxiter (int, None) – The number of inner optimizer steps to perform.

  • polish (False, float) – Whether to polish the result.

  • callback (bool) – Whether to utilize a callback or not.

Returns:

result – The result of the optimization.

Return type:

OptimizeResult, None

rates(x=None)[source]

Compute the Gray-Wyner rate point for an optimization vector.

Parameters:

x (np.ndarray, None) – An optimization vector. If None, use self._optima.

Returns:

point – The common rate and the tuple of private rates.

Return type:

GrayWynerPoint

class GrayWynerPoint(common, private)

Bases: tuple

class IBCurve(dist, rvs=None, crvs=None, beta_min=0.0, beta_max=15.0, beta_num=101, alpha=1.0, method='sp', divergence=None, variant=None, bound=None)[source]

Bases: object

Compute an information bottleneck curve.

compute(method='sp')[source]

Sweep beta and compute the information bottleneck curve.

Parameters:

method ({'sp', 'ba', 'sequential', 'agglomerative'}) – The method of computation to use. ‘sp’ denotes scipy.optimize; ‘ba’ denotes blahut-arimoto; ‘sequential’ and ‘agglomerative’ denote hard deterministic solvers.

find_max_beta()[source]

Find a beta value which maximizes the rate.

Returns:

beta_max – The the smallest found beta value which achieves minimal distortion.

Return type:

float

find_kinks()[source]

Determine the beta values where new features are discovered.

Returns:

kinks – An array of beta values where new features are discovered.

Return type:

np.ndarray

plot(downsample=5)[source]

Construct an IBPlotter and utilize it to plot the information bottleneck curve.

Parameters:

downsample (int) – The how frequent to display points along the IB curve.

Returns:

fig – The resulting figure.

Return type:

plt.figure

class InformationBottleneck(dist, beta, alpha=1.0, rvs=None, crvs=None, bound=None)[source]

Bases: BaseAuxVarOptimizer

Base optimizer for information bottleneck type calculations.

optimize(*args, **kwargs)[source]

Optimize, then keep the best of the result, the seeds, and the deterministic partition encoders, since local search started at a seed can drift away from it.

Parameters:
  • args – Passed to BaseAuxVarOptimizer.optimize().

  • kwargs – Passed to BaseAuxVarOptimizer.optimize().

Returns:

result – The result of the search.

Return type:

OptimizeResult

classmethod functional()[source]

Return a function which computes the result of this optimization.

Returns:

information_bottleneck – The function which performs this optimization.

Return type:

func

class InformationBottleneckDivergence(dist, beta, alpha=1.0, divergence=<function relative_entropy_pmf>, rvs=None, crvs=None, bound=None)[source]

Bases: InformationBottleneck

A generalized information bottleneck which uses a distortion equal to D( p(Y|x) || q(Y|t) ) for an arbitrary divergence measure D.

class InformationBottleneckRate(dist, rate, rvs=None, crvs=None, bound=None)[source]

Bases: InformationBottleneck

The information bottleneck at a fixed rate [TPB00],

\[F(R) = \max_{p(t | x, z) : I[X : T | Z] \leq R} I[Y : T | Z],\]

the information bottleneck curve as a function of the complexity. The curve is concave and non-decreasing, and reaches I[X : Y | Z]. A rate constraint needs one symbol more than the Lagrangian, so the size of T is bounded by |X||Z| + 1.

optimize(*args, **kwargs)[source]

Optimize a few times, then keep the most relevant feasible candidate among the results, the seeds, and the deterministic encoders.

Parameters:
  • args – Passed to BaseAuxVarOptimizer.optimize().

  • kwargs – Passed to BaseAuxVarOptimizer.optimize().

Returns:

result – The result of the search.

Return type:

OptimizeResult

classmethod functional()[source]

Return a function which computes the result of this optimization.

Returns:

information_bottleneck_rate – The function which performs this optimization.

Return type:

func

class MutualInformationPoint(marginals, joint)

Bases: tuple

A point of the mutual information region of [LEG18a].

marginals

The per-source informations I[X_i : W].

Type:

tuple of float

joint

The joint information I[X_{0:n} : W].

Type:

float

class PFCurve(dist, rvs=None, crvs=None, rate_num=26, method='sp', bound=None)[source]

Bases: object

Compute a privacy funnel curve [MSFMedard14]: the least leakage I[S : T | Z] of a release T of X as a function of its utility I[X : T | Z]. It is the lower boundary of the region whose upper boundary is the information bottleneck curve of X with respect to S [AC20].

The curve is swept over utility rates rather than Lagrange multipliers: it is convex, often with a narrow range of slopes, so a sweep over the multiplier would resolve only a few of its points.

compute()[source]

Compute the leakages and utilities along the curve.

plot()[source]

Plot the privacy funnel curve with a BottleneckRegionPlotter.

Returns:

fig – The resulting figure.

Return type:

plt.figure

class PrivacyFunnel(dist, beta, rvs=None, crvs=None, bound=None)[source]

Bases: BaseAuxVarOptimizer

The privacy funnel Lagrangian [MSFMedard14],

\[\min_{p(t | x, z)} I[S : T | Z] - \beta I[X : T | Z],\]

over mappings T of X, so that S - XZ - T. Since I[S : T | Z] <= I[X : T | Z], every beta >= 1 is minimized by releasing T = X, so the whole curve is traced by beta in [0, 1]. The objective is a difference of convex functions of the mapping, so it is non-convex [AC20].

construct_copy_initial()[source]

The identity mapping T = X, within each value of Z.

Returns:

x – An optimization vector.

Return type:

np.ndarray

optimize(*args, **kwargs)[source]

Optimize, then keep the best of the result and the candidate mappings, since local search started at a seed can drift away from it.

Parameters:
  • args – Passed to BaseAuxVarOptimizer.optimize().

  • kwargs – Passed to BaseAuxVarOptimizer.optimize().

Returns:

result – The result of the search.

Return type:

OptimizeResult

classmethod functional()[source]

Return a function which computes the result of this optimization.

Returns:

privacy_funnel – The function which performs this optimization.

Return type:

func

class PrivacyFunnelRate(dist, rate, rvs=None, crvs=None, bound=None)[source]

Bases: PrivacyFunnel

The privacy funnel [MSFMedard14],

\[\mathrm{PF}(R) = \min_{p(t | x, z) : I[X : T | Z] \geq R} I[S : T | Z].\]

The size of T is bounded by |X| + 1; unlike the information bottleneck, |X| does not suffice in general [AC20].

optimize(*args, **kwargs)[source]

Optimize from the identity mapping, which is always feasible, a few times, then keep the best feasible candidate.

Parameters:
  • args – Passed to BaseAuxVarOptimizer.optimize().

  • kwargs – Passed to BaseAuxVarOptimizer.optimize().

Returns:

result – The result of the search.

Return type:

OptimizeResult

classmethod functional()[source]

Return a function which computes the result of this optimization.

Returns:

privacy_funnel_rate – The function which performs this optimization.

Return type:

func

class PrivacyFunnelResult(p_t_given_x: ndarray, leakage: float, utility: float, active: int, assignments: ndarray | None = None, merges: tuple[tuple[int, int], ...] = ())[source]

Bases: object

The result of a finite-alphabet privacy funnel optimization.

p_t_given_x

The privacy mapping \(p(t | x)\).

Type:

np.ndarray

leakage

\(I(S : T)\).

Type:

float

utility

\(I(X : T)\).

Type:

float

active

The number of non-empty released states.

Type:

int

assignments

The hard cluster assignment for each \(x\), when available.

Type:

np.ndarray

merges

The merge sequence, when available.

Type:

tuple[tuple[int, int], …]

class RDCurve(dist, rv=None, crvs=None, beta_min=0, beta_max=10, beta_num=101, alpha=1.0, distortion=('Hamming', <function hamming_distortion>, <class 'dit.rate_distortion.rate_distortion.RateDistortionHamming'>), method=None)[source]

Bases: object

Compute a rate-distortion curve.

find_max_beta()[source]

Find a beta value which maximizes the rate.

Returns:

beta_max – The the smallest found beta value which achieves minimal distortion.

Return type:

float

compute()[source]

Sweep beta and compute the rate-distortion curve.

Parameters:

method ({'sp', 'ba'}) – The method of computation to use. ‘sp’ denotes scipy.optimize; ‘ba’ denotes blahut-arimoto.

plot(downsample=5)[source]

Construct an RDPlotter and utilize it to plot the rate-distortion curve.

Parameters:

downsample (int) – The how frequent to display points along the RD curve.

Returns:

fig – The resulting figure.

Return type:

plt.figure

class ShapeFunction(dist, rvs=None, crvs=None, alphas=None, num=11, niter=None, maxiter=1000, bound=None)[source]

Bases: object

The shape function of a tuple of random variables.

alphas

The sampled directions, shape (num_points, n).

Type:

np.ndarray

values

The shape function at each direction.

Type:

np.ndarray

minima, maxima

The S_min and S_max envelopes at each direction.

Type:

np.ndarray

minimum(alpha)[source]

The S_min envelope, which depends only on the entropy profile.

Parameters:

alpha (array-like) – A direction, or an array of directions with n columns.

Returns:

value – The lower bound at each direction.

Return type:

np.ndarray

maximum(alpha)[source]

The S_max envelope, which depends only on the entropy profile.

Parameters:

alpha (array-like) – A direction, or an array of directions with n columns.

Returns:

value – The upper bound at each direction.

Return type:

np.ndarray

evaluate(alpha, niter=None, maxiter=1000, rng=None)[source]

Evaluate the shape function in a single direction.

Parameters:
  • alpha (array-like) – A direction with n entries, each in [0, 1].

  • niter (int, None) – Number of basin hops.

  • maxiter (int) – Inner optimizer iterations.

Returns:

value – The shape function in that direction.

Return type:

float

compute(niter=None, maxiter=1000)[source]

Evaluate the shape function at every sampled direction.

Parameters:
  • niter (int, None) – Number of basin hops per direction.

  • maxiter (int) – Inner optimizer iterations.

rigidity(tol=0.001)[source]

Where the shape function sits between its two envelopes.

A fraction of zero at every direction means the pair is rigid: its extension profile is as small as the entropy profile permits. A fraction of one means the mutual information is Gacs-Korner extractable.

Parameters:

tol (float) – Directions where S_max - S_min is below this are Shannon-forced and are excluded from the summary.

Returns:

summary – The min, mean, and max of the normalized position, plus booleans reporting rigidity and maximality.

Return type:

dict

plot()[source]

Plot the shape function.

Returns:

fig – The resulting figure.

Return type:

plt.Figure

class TensionPoint(tensions, residual)

Bases: tuple

A point of the region of tension.

tensions

The per-source tensions tau_i = I[X_{-i} : W | X_i].

Type:

tuple of float

residual

The residual dependence tau_res = T[X_{0:n} | W], which for a pair is the conditional mutual information I[X:Y|W].

Type:

float

admits_perfect_privacy(dist, rvs=None)[source]

Determine whether X can be released with non-zero utility and zero leakage about S.

This is the case if and only if the vectors p(S | x), over the support of X, are linearly dependent [CMMedard15]; in particular, whenever |X| > |S|.

Parameters:
  • dist (Distribution) – The distribution of interest.

  • rvs (iterable of iterables, None) – The private variables S and the public variables X. If None, use dist.rvs.

Returns:

perfect – Whether perfect privacy is possible.

Return type:

bool

asymmetric_private_interaction_information(dist, rvs=None, crvs=None, niter=None, maxiter=1000, bound=None)[source]

Compute the asymmetric private interaction information.

\[G_{PNI}(X \to Y) = \max_{U \perp X} I[X{:}Y|U] - I[X{:}Y]\]

the maximal interaction information achievable by a probe independent of the first source [LEG18a]. Operationally, if Alice holds X and must generate Y using only public randomness W, the least leakage I[Y:W] she can achieve is H[Y|X] - G_PNI(X -> Y).

It vanishes exactly when the maximal interaction information does. This quantity is not symmetric; swap rvs for the other direction.

Parameters:
  • dist (Distribution) – The distribution of interest.

  • rvs (list of lists, None) – The two sources, in the order [X, Y]. If None, all variables of dist are used.

  • crvs (list, None) – Variables to condition on.

  • niter (int, None) – Number of basin hops to perform during the optimization.

  • maxiter (int) – The number of iterations of the optimization subroutine to perform.

  • bound (int, None) – Bound the size of the probe variable.

Returns:

G – The asymmetric private interaction information.

Return type:

float

excess_functional_information(pxy, max_functions=200000, reduce=True)[source]

The excess functional information [LEG18b]

\[\Psi(X \to Y) = \inf_{W \perp X} H[Y|W] - I[X:Y],\]

computed exactly. Refining any \(W\) independent of \(X\) by a random function \(F: \mathcal{X} \to \mathcal{Y}\) independent of \(X\) only lowers \(H[Y|W]\), and \(H[Y | F = f] = H[f(X)]\), so the infimum is a linear program over distributions on functions with \(P(f(x) = y) = p(y|x)\).

Three exact reductions shrink that program first:

  • Common part. With \(g\) the Gács-Körner common part (the connected components of the support), a \(W\) independent of \(X\) is independent of \(g\) and of \(X\) given \(g\), and per-block auxiliaries combine into one, so \(\inf H[Y|W] = H[g] + \sum_k p(k) \inf H[Y|W, g = k]\).

  • X to its minimal sufficient statistic about Y. Merging values with identical \(p(y|x)\) leaves the infimum unchanged: an auxiliary for the merged variable lifts by resampling \(X\) given its class independently of \((Y, W)\).

  • Y to its minimal sufficient statistic about X. Merging values with proportional \(p(x|y)\) also leaves it unchanged: given its class \(Y\) is independent of \(X\), so \(W\) can carry an independent draw of \(Y\) for every class.

Parameters:
  • pxy (np.ndarray) – The joint pmf p(x, y), shape (|X|, |Y|).

  • max_functions (int) – Give up (return None) if a reduced block still has more functions than this.

  • reduce (bool) – Whether to apply the reductions (False solves the raw program, for testing).

Returns:

  • psi (float, None) – The excess functional information.

  • inf_h (float, None) – \(\inf_{W \perp X} H[Y|W] = I[X:Y] + \Psi\), the height of the corner \((H[X], I + \Psi, I + \Psi)\) of the extension profile.

extension_to_rates(extension, joint_entropy)[source]

Convert extension-profile coordinates back to a Gray-Wyner rate point.

Inverts rates_to_extension().

Parameters:
  • extension (ExtensionPoint) – The point of the extension profile.

  • joint_entropy (float) – The joint entropy H[X_{0:n}].

Returns:

point – The corresponding Gray-Wyner rate point.

Return type:

GrayWynerPoint

greedy_privacy_funnel(p_sx, rate=0.0)[source]

Greedily merge released symbols for the privacy funnel [MSFMedard14].

Starting from \(T = X\), repeatedly merge the pair of symbols of \(T\) whose merger most reduces the leakage \(I(S : T)\) while keeping the utility \(I(X : T) \geq R\), until no merge is feasible. Each step is locally optimal; the result need not be globally optimal.

Parameters:
  • p_sx (np.ndarray) – Joint distribution with axis 0 indexing the private \(S\) and axis 1 indexing the public \(X\).

  • rate (float) – The minimum utility \(R\), in bits. Must lie in \([0, H(X)]\).

Returns:

result – The hard privacy mapping found.

Return type:

PrivacyFunnelResult

Raises:

ditException – If rate is outside \([0, H(X)]\).

hamming_matrix(k)[source]

Construct a k x k Hamming distortion matrix.

Parameters:

k (int) – The alphabet size.

Returns:

d – The distortion matrix, 1 - I.

Return type:

np.ndarray

information_bottleneck_rate(dist, rate, rvs=None, crvs=None, bound=None, niter=None, maxiter=None, rng=None)

Compute the information bottleneck at a fixed rate: the largest relevance I[Y : T | Z] of a representation T of X with complexity I[X : T | Z] <= rate [TPB00].

Parameters:
  • dist (Distribution) – The distribution of interest.

  • rate (float) – The maximum complexity, in bits.

  • rvs (iter of iters, None) – The variables X and Y. If None, use dist.rvs.

  • crvs (iter, None) – The random variables to condition on.

  • bound (int, None) – The bound on the size of T. If None, use |X||Z| + 1.

  • niter (int, None) – The number of basin hops to perform.

  • maxiter (int, None) – The number of iterations of the optimization subroutine.

  • rng (np.random.Generator, int, None) – Source of randomness for the optimizer.

Returns:

relevance – The maximal relevance.

Return type:

float

korner_graph_entropy(pxy, max_sets=5000, iters=5000, reduce=True)[source]

Körner’s graph entropy [Korner73] of the characteristic graph of \(X\) (two values are adjacent when some \(y\) is compatible with both),

\[H_K(X) = \min_{X \in U \in \Gamma} I[X:U],\]

with \(\Gamma\) the maximal independent sets. In the extension profile it fixes the point \((x, H[Y|X] + x, x)\) with \(x = H[X] - H_K(X)\) on the edge \(U - X - Y\), \(H[X|Y, U] = 0\) [LEG18a].

The graph is first reduced by substitution [Korner73]: values with the same support set are adjacent twins, so each class collapses to one vertex at a cost of \(p(\text{class}) H[X|\text{class}]\); a disconnected graph contributes the weighted entropies of its components, and a join (disconnected complement) adds the entropy of the part masses. Only prime graphs enumerate maximal independent sets, on which the convex minimization is solved by Blahut-Arimoto style alternating minimization.

Parameters:
  • pxy (np.ndarray) – The joint pmf p(x, y).

  • max_sets (int) – Give up (return None) if a prime graph has more maximal independent sets.

  • iters (int) – Alternating-minimization iterations.

  • reduce (bool) – Whether to apply the reductions (False enumerates on the full graph, for testing).

Returns:

h_k – The graph entropy.

Return type:

float, None

lossy_wyner_common_information(dist, distortion_bounds=None, distortions=None, rvs=None, crvs=None, niter=None, maxiter=1000, bound=None)[source]

The lossy Wyner common information C(D_1, ..., D_n).

This is the minimum common rate R_0 = I(X_{1:n} : W) over auxiliary variables W that place the network on its minimum sum-rate face while meeting every distortion budget (Viswanatha, Akyol, & Rose 2014). For D_i = 0 (lossless) it coincides with the standard Wyner common information.

Parameters:
  • dist (Distribution) – The source distribution.

  • distortion_bounds (list, None) – Per-decoder distortion budgets D_i. If None (or all zero), the lossless Wyner common information is returned.

  • distortions (list, None) – Per-decoder distortion matrices (None entries are lossless).

  • rvs (list of lists, None) – The source groups. If None, each variable is its own source.

  • crvs (list, None) – Variables to condition on.

  • niter (int, None) – Number of basin hops.

  • maxiter (int) – Inner optimizer iterations.

  • bound (int, None) – Optional cap on the cardinality of W.

Returns:

C – The lossy Wyner common information.

Return type:

float

maximal_interaction_information(dist, rvs=None, crvs=None, niter=None, maxiter=1000, bound=None)[source]

Compute the maximal interaction information.

\[G_{NNI}(X : Y) = \max_U I[X{:}Y|U] - I[X{:}Y]\]

the largest amount by which a probe can increase the dependence between X and Y [LEG18a]. It vanishes exactly when the support graph contains no path of length three, equivalently when p(x|y) = 1 or p(y|x) = 1 at every outcome of positive probability, and is bounded above by min{H[X|Y], H[Y|X]}.

Parameters:
  • dist (Distribution) – The distribution of interest.

  • rvs (list of lists, None) – The two sources. If None, all variables of dist are used.

  • crvs (list, None) – Variables to condition on.

  • niter (int, None) – Number of basin hops to perform during the optimization.

  • maxiter (int) – The number of iterations of the optimization subroutine to perform.

  • bound (int, None) – Bound the size of the probe variable.

Returns:

G – The maximal interaction information.

Return type:

float

mutual_information_to_rates(info, marginal_entropies)[source]

Convert mutual information coordinates back to a Gray-Wyner rate point.

Inverts rates_to_mutual_information().

Parameters:
  • info (MutualInformationPoint) – The point of the mutual information region.

  • marginal_entropies (iterable of float) – The marginal entropies H[X_i].

Returns:

point – The corresponding Gray-Wyner rate point.

Return type:

GrayWynerPoint

perfect_privacy_utility(dist, rvs=None, return_mechanism=False, max_candidates=100000)[source]

Compute the maximal utility at perfect privacy,

\[g_0 = \max_{p(t | x) : I(S : T) = 0} I(X : T),\]

exactly, by enumerating the vertices of the perfect privacy polytope and solving a linear program [RGunduz21].

Parameters:
  • dist (Distribution) – The distribution of interest.

  • rvs (iterable of iterables, None) – The private variables S and the public variables X. If None, use dist.rvs.

  • return_mechanism (bool) – If True, also return an optimal mapping p(t | x).

  • max_candidates (int) – The maximum number of column bases to enumerate.

Returns:

  • g0 (float) – The maximal utility, in bits, of a release leaking nothing about S.

  • p_t_given_x (np.ndarray) – An optimal mapping of shape (|X|, |T|), if return_mechanism.

Raises:

ditException – If the polytope has too many candidate bases.

privacy_funnel(dist, beta, rvs=None, crvs=None, bound=None)

Compute a point on the privacy funnel by minimizing I[S : T | Z] - beta I[X : T | Z] [MSFMedard14].

Parameters:
  • dist (Distribution) – The distribution of interest.

  • beta (float) – The non-negative price of utility.

  • rvs (iterable of iterables, None) – The private variables S and the public variables X. If None, use dist.rvs.

  • crvs (iterable, None) – The random variables to condition on.

  • bound (int, None) – The bound on the size of T. If None, use |X|.

Returns:

  • leakage (float) – I[S : T | Z] at the optimum.

  • utility (float) – I[X : T | Z] at the optimum.

privacy_funnel_rate(dist, rate, rvs=None, crvs=None, bound=None)

Compute the privacy funnel, the least leakage I[S : T | Z] of a release T of X with utility I[X : T | Z] >= rate [MSFMedard14].

Parameters:
  • dist (Distribution) – The distribution of interest.

  • rate (float) – The minimum utility, in bits.

  • rvs (iterable of iterables, None) – The private variables S and the public variables X. If None, use dist.rvs.

  • crvs (iterable, None) – The random variables to condition on.

  • bound (int, None) – The bound on the size of T. If None, use |X| + 1.

Returns:

pf – The minimal leakage.

Return type:

float

rates_to_extension(point, joint_entropy)[source]

Convert a Gray-Wyner rate point to extension-profile coordinates.

The private rates are the conditional entropies H[X_i | W], so this map only computes the residual coordinate.

Parameters:
  • point (GrayWynerPoint) – The rate point (R_0, (R_1, ..., R_n)).

  • joint_entropy (float) – The joint entropy H[X_{0:n}].

Returns:

extension – The corresponding point of the extension profile.

Return type:

ExtensionPoint

rates_to_mutual_information(point, marginal_entropies)[source]

Convert a Gray-Wyner rate point to mutual information coordinates.

Parameters:
  • point (GrayWynerPoint) – The rate point (R_0, (R_1, ..., R_n)).

  • marginal_entropies (iterable of float) – The marginal entropies H[X_i].

Returns:

info – The corresponding point of the mutual information region.

Return type:

MutualInformationPoint

rates_to_tension(point, marginal_entropies, joint_entropy)[source]

Convert a Gray-Wyner rate point to tension coordinates.

Parameters:
  • point (GrayWynerPoint) – The rate point (R_0, (R_1, ..., R_n)).

  • marginal_entropies (iterable of float) – The marginal entropies H[X_i].

  • joint_entropy (float) – The joint entropy H[X_{0:n}].

Returns:

tension – The corresponding point of the region of tension.

Return type:

TensionPoint

symmetric_private_interaction_information(dist, rvs=None, crvs=None, niter=None, maxiter=1000, bound=None)[source]

Compute the symmetric private interaction information.

\[G_{PPI}(X : Y) = \max_{U \perp X,\, U \perp Y} I[X{:}Y|U] - I[X{:}Y] = \max_{U \perp X,\, U \perp Y} I[XY{:}U]\]

the most that can be disclosed about the pair while telling an eavesdropper holding either source alone nothing [LEG18a]. It vanishes exactly when the support graph is acyclic.

Parameters:
  • dist (Distribution) – The distribution of interest.

  • rvs (list of lists, None) – The two sources. If None, all variables of dist are used.

  • crvs (list, None) – Variables to condition on.

  • niter (int, None) – Number of basin hops to perform during the optimization.

  • maxiter (int) – The number of iterations of the optimization subroutine to perform.

  • bound (int, None) – Bound the size of the probe variable.

Returns:

G – The symmetric private interaction information.

Return type:

float

tension_to_rates(tension, marginal_entropies, joint_entropy)[source]

Convert tension coordinates back to a Gray-Wyner rate point.

Inverts rates_to_tension(). Summing the per-source tensions and subtracting the residual eliminates the private rates and leaves (n - 1) R_0, which is why at least two sources are required.

Parameters:
  • tension (TensionPoint) – The point of the region of tension.

  • marginal_entropies (iterable of float) – The marginal entropies H[X_i].

  • joint_entropy (float) – The joint entropy H[X_{0:n}].

Returns:

point – The corresponding Gray-Wyner rate point.

Return type:

GrayWynerPoint