pyBregMan: A Python library for Bregman Manifolds

Frank Nielsen, Alexander SoenarXiv 2024 · DOI · arXiv

Abstract

pyBregMan is a Python library designed to facilitate the application of information geometry—specifically Bregman and Fisher-Rao manifolds—in practical research. By leveraging Legendre-Fenchel duality and automatic differentiation, it provides a unified geometric kernel for computing divergences, geodesics, and centroids across various statistical models. This paper introduces the library's core principles, technical implementation, and illustrative applications in Gaussian centroids, matrix means, and information theory.

Introduction

Information geometry treats statistical models as manifolds—curved surfaces where "distance" represents the dissimilarity between probability distributions. While mathematically elegant, implementing these concepts, such as dually flat spaces or Fisher-Rao metrics, is notoriously difficult and error-prone. Researchers often have to "reinvent the wheel" to calculate geometric means or Chernoff information points. pyBregMan fills this gap by providing a standardized, extensible API for these complex geometric operations.

Methodology

The library is built around the core principle of Legendre-Fenchel duality. In this framework, a single strictly convex "generator" function $F$ induces a manifold with two coupled coordinate systems ($\theta$ and $\eta$) and a pair of dual Bregman divergences.

Technical Implementation

  • Auto-Differentiation: Using the autograd library, pyBregMan automatically computes the gradients and Hessians of user-defined convex generators. This allows users to define a new manifold by simply writing a standard Python function for the potential.
  • Geometric Primitives: The library defines abstract classes for Point, Manifold, Geodesic, and Bisector. It handles coordinate transformations (e.g., moving between "natural" and "expectation" parameters) behind the scenes.
  • Duality as a First-Class Citizen: Many statistical quantities are defined by the interaction of primal and dual spaces. For example, the Chernoff point is found at the intersection of a primal geodesic and a dual bisector. pyBregMan maps these mathematical concepts directly to an object-oriented hierarchy.

Applications and Results

The library comes pre-loaded with implementations for common models, including Multivariate Gaussians, Categorical distributions, and Positive Semi-definite (PSD) matrix cones. Its utility is showcased through several "visual vignettes":

Centroid Computation

pyBregMan successfully calculates and visualizes different types of centroids. The following figure demonstrates the computation of Left-KL, Right-KL, Bhattacharyya, and Fisher-Rao centroids for bivariate Gaussians.

Centroid computation for bivariate Gaussians using different geometric metrics.

Matrix Means and Information Theory

  • PSD Matrices: The library demonstrates the convergence of the inductive arithmetic-harmonic mean (AHM) algorithm, which converges quadratically to the geometric mean of PSD matrices.
  • Chernoff Information: It provides a clean implementation for finding the Chernoff point on a 1D Gaussian manifold.
  • Image Histograms: Jensen-Shannon and Jeffreys centroids were computed for pixel intensity histograms from source images to demonstrate operations on categorical manifolds.

Discussion and Limitations

While powerful, pyBregMan has areas for growth. For high-precision applications, users are encouraged to provide explicit analytical derivatives to avoid the numerical overhead of autograd. Additionally, visualization tools are currently optimized for 2D and 3D projections, and some geometric objects like the Ball class have limited functionality beyond membership testing.

Conclusion

By providing a robust geometric kernel, pyBregMan bridges the gap between theoretical information geometry and practical code. It enables researchers to focus on high-level statistical modeling rather than low-level geometric implementation.

Summary updated

Abstract

A Bregman manifold is a synonym for a dually flat space in information geometry which admits as a canonical divergence a Bregman divergence. Bregman manifolds are induced by smooth strictly convex functions like the cumulant or partition functions of regular exponential families, the negative entropy of mixture families, or the characteristic functions of regular cones just to list a few such convex Bregman generators. We describe the design of pyBregMan, a library which implements generic operations on Bregman manifolds and instantiate several common Bregman manifolds used in information sciences. At the core of the library is the notion of Legendre-Fenchel duality inducing a canonical pair of dual potential functions and dual Bregman divergences. The library also implements the Fisher-Rao manifolds of categorical/multinomial distributions and multivariate normal distributions. To demonstrate the use of the pyBregMan kernel manipulating those Bregman and Fisher-Rao manifolds, the library also provides several core algorithms for various applications in statistics, machine learning, information fusion, and so on.
BibTeX
@misc{nielsen2024pybregman,
  author = {Frank Nielsen and Alexander Soen},
  title = {{pyBregMan: A Python library for Bregman Manifolds}},
  year = {2024},
  eprint = {2408.04175},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.04175},
}
Figure