Skip to content
Edit this page View source of this page

optora.divergences.max_divergence

Max-divergence (Renyi divergence of order infinity) between distributions.

MaxDivergence

Bases: Divergence

Max-divergence of a candidate distribution from a reference.

For discrete distributions represented as nonnegative tensors that sum to one along their last dimension, computes the logarithm of the largest likelihood ratio,

\[ D_\infty(p \,\|\, q) = \log \max_i \frac{p_i}{q_i}, \]

the Renyi divergence of order \(\infty\) (van Erven and Harremoes 2014), also called the max-divergence (Dwork and Roth 2014). It is infinite when p puts mass where q has none, and the clamp described below replaces that infinity by a large finite value. Its ball of radius \(\log(1/\alpha)\) is exactly the set of distributions with likelihood ratio at most \(1/\alpha\), which optora.dro.phi_dro.CVaRAmbiguitySet uses to express conditional value-at-risk as an ambiguity set.

Attributes:

Name Type Description
eps

Small positive constant used to clamp q away from zero before dividing, so a candidate leaving the reference's support yields a large finite value rather than inf or nan.

__init__(eps=1e-12)

Initialize the max-divergence.

Parameters:

Name Type Description Default
eps float

Small positive constant used to clamp q away from zero before dividing.

1e-12

Raises:

Type Description
ValueError

If eps is not positive.

forward(p, q)

Compute the max-divergence of p from q.

Parameters:

Name Type Description Default
p Tensor

Candidate distribution of shape (..., n), nonnegative and summing to one along its last dimension.

required
q Tensor

Reference distribution of shape (..., n), broadcasting against p.

required

Returns:

Type Description
Tensor

\(D_\infty(p \,\|\, q)\) over the broadcast batch, of shape

Tensor

(...), clamped to be nonnegative to absorb floating-point

Tensor

error near zero, computed in optora.core.working_dtype(p, q)

Tensor

and returned in the promoted dtype of p and q.