Notes:
- Environments: Python 3.10.10, Geomstats 2.7.0
- This article assumes that the reader is somewhat familiar with differential and tensor calculus [ref 1]. Please refer to our previous articles related to geometric learning listed on Appendix.
- Source code is available at Github.com/patnicolas/Data_Exploration/Information Geometry
- To enhance the readability of the algorithm implementations, we have omitted non-essential code elements like error checking, comments, exceptions, validation of class and method arguments, scoping qualifiers, and import statements.
Introduction
- Brief introduction to information geometry
- Overview and mathematical formulation of the Fisher information matrix
- Computation of the Fisher metric to Normal and Beta distributions
- Implementation in Python using the Geomstats library
Information geometry
Use cases
- Statistical Inference: Parameter estimation, hypothesis testing, and model selection (i.e. Bayesian posterior distributions and in the development of efficient sampling algorithms like Hamiltonian Monte Carlo)
- Optimization: Natural gradient descent method uses the Fisher information matrix to adjust the learning rate dynamically, leading to faster convergence compared to traditional gradient descent.
- Finance: Modeling uncertainties and analyzing statistical properties of financial models.
- Machine Learning: Optimization of learning algorithms (i.e. Understanding the EM algorithm used in statistical estimation for latent variable model)
- Neuroscience: Neural coding and information processing in the brain by modeling neural responses as probability distributions.
- Robotics: Development of probabilistic robotics, where uncertainty and sensor noise are modeled using probability distributions.
- Information Theory: Concepts for encoding, compression, and transmission of information.
Fisher information matrix
Implementation
- ManifoldPoint in Riemann Metric & Connection for Geometric Learning - Setup
- HypersphereSpace in Differentiable Manifolds for Geometric Learning - Hypersphere
class GeometricDistribution(object):
_ZERO_TGT_VEC = [0.0, 0.0, 0.0]
def __init__(self) -> None:
self.manifold = HypersphereSpace(True)
def show_points(self,
num_pts: int,
tgt_vector: List[float] = _ZERO_TGT_VEC) -> NoReturn:
# Random point generated on the hypersphere
manifold_pts = self._random_manifold_points(num_pts, tgt_vector)
# Exponential map used to project the tgt vector on the hypersphere
exp_map = self.manifold.tangent_vectors(manifold_pts)
for v, end_pt in exp_map:
print(f'Tangent vector: {v} End point: {end_pt}')
self.manifold.show_manifold(manifold_pts)
Normal distribution
class NormalHypersphere(GeometricDistribution):
from geomstats.information_geometry.normal import NormalDistributions
def __init__(self) -> None:
super(NormalHypersphere, self).__init__()
self.normal = NormalDistributions(sample_dim=1)
def show_distribution(self,
num_pdfs: int,
num_manifold_pts: int) -> NoReturn:
manifold_pts = self._random_manifold_points(num_manifold_pts)
A = manifold_pts[0]
B = manifold_pts[1]
# Apply the Fisher metric for the two manifold points
# on a Hypersphere
geodesic_ab_fisher = self.normal.metric.geodesic(A.location,
B.location)
t = gs.linspace(0, 1, 100)
# Generate the various density functions associated to
# the Fisher metric between the two points on the hypersphere
pdfs = self.normal.point_to_pdf(geodesic_ab_fisher(t))
x = gs.linspace(0.2, 0.7, num_pdfs)
for i in range(num_pdfs):
plt.plot(x, pdfs(x)[i, :]/20.0) # Normalization factor
plt.title(f'Normal distribution on Hypersphere')
plt.show()
normal_dist = NormalHypersphere()
num_points = 2
tangent_vector = [0.4, 0.7, 0.2]
# 1. Display the 2 data points on the hypersphere
num_manifold_pts = normal_dist.show_points(num_points,
tangent_vector)
# 2. Visualize the 40 normal probabilities density functions
num_pdfs = 40
succeeded = normal_dist.show_distribution(num_pdfs, num_points)
Beta distribution
class BetaHypersphere(GeometricDistribution):
from geomstats.information_geometry.beta import BetaDistributions
def __init__(self) -> None:
super(BetaHypersphere, self).__init__()
self.beta = BetaDistributions()
def show_distribution(self,
num_manifold_pts: int,
num_interpolations: int) -> NoReturn:
# 1. Generate random points on Hypersphere -Von Mises algorithm
manifold_pts = self._random_manifold_points(num_manifold_pts)
t = gs.linspace(0, 1.1, num_interpolations)[1:]
# 2. Define the beta pdfs associated with each
beta_values_pdfs = [self.beta.point_to_pdf(manifold_pt.location)(t)
for manifold_pt in manifold_pts]
# 3. Generate, normalize and display each Beta distribution
for beta_values in beta_values_pdfs:
min_beta = min(beta_values)
delta_beta = max(beta_values) - min_beta
y = [(beta_value - min_beta)/delta_beta
for beta_value in beta_values] plt.plot(t, y) plt.title(f'Beta distribution on Hypersphere') plt.show()
beta_dist = BetaHypersphere()
num_interpolations = 200
num_manifold_pts = 10
# 1. Display the 10 data points on the hypersphere beta_dist.show_points(num_manifold_pts)
# 2. Visualize the probabilities density functions with
# interpolation points
succeeded = beta_dist.show_distribution(num_manifold_pts,
num_interpolations)