rankseg.distribution

Classes

RefinedNormalPB

Refined Normal distribution to approximate Poisson binomial distribution.

RefinedNormal

Refined Normal distribution to approximate Poisson binomial distribution.

Module Contents

class rankseg.distribution.RefinedNormalPB(dim: torch.Tensor | int, loc: torch.Tensor | float, scale: torch.Tensor | float, skew: torch.Tensor | float, validate_args: bool | None = None)

Bases: torch.distributions.Distribution

Refined Normal distribution to approximate Poisson binomial distribution.

The CDF is defined as:

\[F(k; skew) = G( (k + 0.5 - loc) / scale ); \quad G(x) = \Phi(x) + skew * (1 - x^2) * \phi(x) / 6\]

where:

  • Phi(x) is the standard normal CDF

  • phi(x) is the standard normal PDF

  • skew is the skewness parameter

The PDF is defined as:

Args:

skew: Skewness parameter controlling the third moment correction term. validate_args: Whether to validate the arguments.

expand(batch_shape, _instance=None)

Returns a new distribution instance (or populates an existing instance provided by a derived class) with batch dimensions expanded to batch_shape. This method calls expand on the distribution’s parameters. As such, this does not allocate new memory for the expanded distribution instance. Additionally, this does not repeat any args checking or parameter broadcasting in __init__.py, when an instance is first created.

Args:

batch_shape (torch.Size): the desired expanded size. _instance: new instance provided by subclasses that

need to override .expand.

Returns:

New distribution instance with batch dimensions expanded to batch_size.

cdf(value)

Returns the cumulative density/mass function evaluated at value.

Args:

value (Tensor):

pdf(value)
pmf(value)
icdf(p, max_iter=1000, tol=1e-06)

Inverse CDF (quantile function) using bracketed bisection.

Parameters

ptorch.Tensor

Probability values (0 < p < 1)

max_iterint, optional

Maximum number of iterations (default: 50)

tolfloat, optional

Tolerance for convergence (default: 1e-6)

Returns

torch.Tensor

Quantile values corresponding to probabilities p

interval(p)

Compute the confidence interval [lq, uq] such that P(lq <= X <= uq) = 1 - p.

class rankseg.distribution.RefinedNormal

Bases: scipy.stats.rv_continuous

Refined Normal distribution to approximate Poisson binomial distribution.

This class extends the continuous random variable class from SciPy to implement a modified normal distribution with a skewness correction term. The distribution is particularly effective for approximating the Poisson binomial distribution (the sum of independent but non-identical Bernoulli random variables).

The CDF is defined as: F(x; skew) = Φ(x) + skew * (1 - x²) * φ(x) / 6

where:

  • Φ(x) is the standard normal CDF

  • φ(x) is the standard normal PDF

  • skew is the skewness parameter

Parameters

skewfloat

Skewness parameter controlling the third moment correction term. Must be a finite value.

Notes

This refined approximation offers improved accuracy over the standard normal approximation by incorporating a skewness correction term [3].

In the context of RankSEG, this distribution is used to efficiently approximate the Poisson binomial distribution.

References

[3] Volkova, A.Y., 1996. A refinement of the central limit theorem for sums of independent random indicators. Theory of Probability and its Applications 40, 791-794.