geomstats.information_geometry package#

Subpackages#

Submodules#

geomstats.information_geometry.base module#

Mixin for manifolds of probability distributions.

class geomstats.information_geometry.base.InformationManifoldMixin(support_shape, **kwargs)[source]#

Bases: object

Mixin for manifolds of probability distributions.

point_to_cdf(point)[source]#

Compute cdf associated to point.

Compute the cumulative density function of the probability distribution with parameters provided by point.

Parameters:

point (array-like, shape=[…, dim]) – Point representing a probability distribution.

Returns:

cdf (function) – Cumulative density function of the probability distribution with parameters provided by point.

point_to_pdf(point)[source]#

Compute pdf associated to point.

Compute the probability density function of the probability distribution with parameters provided by point.

Parameters:

point (array-like, shape=[…, dim]) – Point representing a probability distribution.

Returns:

pdf (function) – Probability density function of the probability distribution with parameters provided by point.

sample(point, n_samples=1)[source]#

Sample from the probability distribution.

Sample from the probability distribution with parameters provided by point. This gives n_samples points.

Parameters:
  • point (array-like, shape=[…, dim]) – Point representing a probability distribution.

  • n_samples (int) – Number of points to sample for each set of parameters in point.

Returns:

samples (array-like, shape=[…, n_samples]) – Sample from the probability distributions.

class geomstats.information_geometry.base.ScipyMultivariateRandomVariable(space, scp_rvs, scp_pdf=None)[source]#

Bases: ScipyRandomVariable

A multivariate random variable.

pdf(x, point)[source]#

Evaluate the probability density function at x.

Parameters:
  • x (array-like, shape=[n_samples, *support_shape]) – Sample points at which to compute the probability density function.

  • point (array-like, shape=[…, *space.shape]) – Point representing a distribution.

Returns:

pdf_at_x (array-like, shape=[…, n_samples, *support_shape]) – Values of pdf at x for each value of the parameters provided by point.

rvs(point, n_samples=1)[source]#

Sample from a multivariate distribution.

Parameters:
  • point (array-like, shape=[…, *space.shape]) – Point representing a distribution.

  • n_samples (int) – Number of points to sample with each pair of parameters in point.

Returns:

samples (array-like, shape=[…, n_samples, *support_shape]) – Sample from distribution.

class geomstats.information_geometry.base.ScipyRandomVariable(space, scp_rvs, scp_pdf=None)[source]#

Bases: object

A random variable.

class geomstats.information_geometry.base.ScipyUnivariateRandomVariable(space, scp_rvs, scp_pdf=None)[source]#

Bases: ScipyRandomVariable

A univariate random variable.

pdf(sample, point)[source]#

Evaluate the probability density function at x.

Parameters:
  • x (array-like, shape=[n_samples, *support_shape]) – Sample points at which to compute the probability density function.

  • point (array-like, shape=[…, *space.shape]) – Point representing a distribution.

Returns:

pdf_at_x (array-like, shape=[…, n_samples]) – Values of pdf at x for each value of the parameters provided by point.

rvs(point, n_samples=1)[source]#

Sample from a univariate distribution.

Parameters:
  • point (array-like, shape=[…, *space.shape]) – Point representing a univariate distribution.

  • n_samples (int) – Number of points to sample with each pair of parameters in point.

Returns:

samples (array-like, shape=[…, n_samples, *support_shape]) – Sample from distribution.

geomstats.information_geometry.beta module#

Statistical Manifold of beta distributions with the Fisher metric.

Lead author: Alice Le Brigant.

class geomstats.information_geometry.beta.BetaDistributions(equip=True)[source]#

Bases: DirichletDistributions

Class for the manifold of beta distributions.

This is Beta = \(R_+^* \times R_+^*\), the upper-right quadrant of the Euclidean plane.

Parameters:

equip (bool) – If True, equip space with default metric.

static default_metric()[source]#

Metric to equip the space with if equip is True.

static maximum_likelihood_fit(data, loc=0, scale=1, epsilon=1e-06)[source]#

Estimate parameters from samples.

This a wrapper around scipy’s maximum likelihood estimator to estimate the parameters of a beta distribution from samples.

Parameters:
  • data (array-like, shape=[…, n_samples]) – Data to estimate parameters from. Arrays of different length may be passed.

  • loc (float) – Location parameter of the distribution to estimate parameters from. It is kept fixed during optimization.

  • scale (float) – Scale parameter of the distribution to estimate parameters from. It is kept fixed during optimization.

Returns:

parameter (array-like, shape=[…, 2]) – Estimate of parameter obtained by maximum likelihood.

point_to_pdf(point)[source]#

Compute pdf associated to point.

Compute the probability density function of the beta distribution with parameters provided by point.

Parameters:

point (array-like, shape=[…, 2]) – Point representing a beta distribution.

Returns:

pdf (function) – Probability density function of the beta distribution with parameters provided by point.

sample(point, n_samples=1)[source]#

Sample from the beta distribution.

Sample from the beta distribution with parameters provided by point. This gives samples in the segment [0, 1].

Parameters:
  • point (array-like, shape=[…, 2]) – Point representing a beta distribution.

  • n_samples (int) – Number of points to sample with each pair of parameters in point.

Returns:

samples (array-like, shape=[…, n_samples]) – Sample from beta distributions.)

class geomstats.information_geometry.beta.BetaDistributionsRandomVariable(space)[source]#

Bases: ScipyUnivariateRandomVariable

A beta random variable.

class geomstats.information_geometry.beta.BetaMetric(space)[source]#

Bases: DirichletMetric

Class for the Fisher information metric on beta distributions.

christoffels(base_point)[source]#

Compute the Christoffel symbols.

Compute the Christoffel symbols of the Fisher information metric.

Parameters:

base_point (array-like, shape=[…, 2]) – Base point.

Returns:

christoffels (array-like, shape=[…, 2, 2, 2]) – Christoffel symbols, with the contravariant index on the first dimension. \(christoffels[..., i, j, k] = Gamma^i_{jk}\)

gaussian_curvature(base_point)[source]#

Compute the Gaussian curvature.

The Gaussian curvature of the Fisher information metric is [LP2019]:

\[K = \frac{\psi''(a) \psi''(b) \psi''(a + b)}{4 \det(g)^2} \left( \frac{\psi'(a)}{\psi''(a)} + \frac{\psi'(b)}{\psi''(b)} - \frac{\psi'(a + b)}{\psi''(a + b)} \right)\]

where \(\psi\) is the digamma function and \(g\) the metric matrix.

Parameters:

base_point (array-like, shape=[…, 2]) – Base point.

Returns:

curvature (array-like, shape=[…,]) – Gaussian curvature at base_point.

References

[LP2019]

A. Le Brigant, S. Puechmorel. The Fisher-Rao geometry of beta distributions applied to the study of canonical moments. arXiv:1904.08247, 2019.

static metric_det(point)[source]#

Compute the determinant of the metric.

Parameters:

point (array-like, shape=[…, 2]) – Point representing a beta distribution.

Returns:

metric_det (array-like, shape=[…,]) – Determinant of the metric.

metric_matrix(base_point)[source]#

Compute the inner-product matrix.

Compute the inner-product matrix of the Fisher information metric at the tangent space at base point.

Parameters:

base_point (array-like, shape=[…, 2]) – Base point.

Returns:

mat (array-like, shape=[…, 2, 2]) – Inner-product matrix.

riemann_tensor(base_point)[source]#

Compute Riemannian tensor at base_point.

In dimension two, the curvature is determined by the Gaussian curvature \(K\): \(R(X, Y)Z = K (\langle Y, Z \rangle X - \langle X, Z \rangle Y)\), i.e. \(R_{ijk}^l = K (g_{ki} \delta_j^l - g_{ji} \delta_k^l)\).

Parameters:

base_point (array-like, shape=[…, 2]) – Base point.

Returns:

riemann_curvature (array-like, shape=[…, 2, 2, 2, 2]) – riemann_tensor[…,i,j,k,l] = R_{ijk}^l Riemannian tensor curvature, with the contravariant index on the last dimension.

scalar_curvature(base_point)[source]#

Compute scalar curvature at base_point.

The space is two-dimensional, so the scalar curvature is twice the Gaussian curvature.

Parameters:

base_point (array-like, shape=[…, 2]) – Base point.

Returns:

curvature (array-like, shape=[…,]) – Scalar curvature.

sectional_curvature(tangent_vec_a, tangent_vec_b, base_point)[source]#

Compute the sectional curvature.

The space is two-dimensional, so the sectional curvature is the Gaussian curvature, whatever the tangent vectors (including collinear ones, for which the general definition is degenerate).

Parameters:
  • tangent_vec_a (array-like, shape=[…, 2]) – Tangent vector at base_point.

  • tangent_vec_b (array-like, shape=[…, 2]) – Tangent vector at base_point.

  • base_point (array-like, shape=[…, 2]) – Base point.

Returns:

sectional_curvature (array-like, shape=[…,]) – Sectional curvature at base_point.

geomstats.information_geometry.binomial module#

Statistical Manifold of Binomial distributions with the Fisher metric.

Lead authors: Jules Deschamps, Tra My Nguyen.

class geomstats.information_geometry.binomial.BinomialDistributions(n_draws, equip=True)[source]#

Bases: InformationManifoldMixin, OpenInterval

Class for the manifold of binomial distributions.

This is the parameter space of binomial distributions i.e. the interval (0, 1).

Parameters:
  • n_draws (int) – Number of draws.

  • equip (bool) – If True, equip space with default metric.

static default_metric()[source]#

Metric to equip the space with if equip is True.

point_to_pdf(point)[source]#

Compute pmf associated to point.

Compute the probability mass function of the binomial distribution with parameters provided by point.

Parameters:

point (array-like, shape=[…, 1]) – Point representing a binomial distribution (probability of success).

Returns:

pmf (function) – Probability mass function of the binomial distribution with parameters provided by point.

sample(point, n_samples=1)[source]#

Sample from the binomial distribution.

Sample from the binomial distribution with parameter provided by point.

Parameters:
  • point (array-like, shape=[…, dim]) – Point representing a binomial distribution.

  • n_samples (int) – Number of points to sample with for each parameter in point.

Returns:

samples (array-like, shape=[…, n_samples, dim]) – Sample from binomial distributions.

class geomstats.information_geometry.binomial.BinomialDistributionsRandomVariable(space)[source]#

Bases: ScipyUnivariateRandomVariable

A binomial random variable.

pdf(x, point)[source]#

Evaluate the probability density function at x.

Parameters:
  • x (array-like, shape=[n_samples, *support_shape]) – Sample points at which to compute the probability density function.

  • point (array-like, shape=[…, *space.shape]) – Point representing a distribution.

Returns:

pdf_at_x (array-like, shape=[…, n_samples, *support_shape]) – Values of pdf at x for each value of the parameters provided by point.

class geomstats.information_geometry.binomial.BinomialMetric(space)[source]#

Bases: FlatCoordinateMixin, CoordinatePullbackDiffeoMetric

Class for the Fisher information metric on binomial distributions.

It is the pullback of the Euclidean metric on the interval \((0, \pi \sqrt{n})\) through ArcsinSqrtDiffeo. The space is one-dimensional, so the metric is flat.

References

[AM1981]

Atkinson, C., & Mitchell, A. F. (1981). Rao’s distance measure. Sankhyā: The Indian Journal of Statistics, Series A, 345-365.

christoffels(base_point)[source]#

Compute the Christoffel symbols.

The only symbol is \(\Gamma^p_{pp} = -1 / (2 p) + 1 / (2 (1 - p))\).

Parameters:

base_point (array-like, shape=[…, 1]) – Base point.

Returns:

christoffels (array-like, shape=[…, 1, 1, 1]) – Christoffel symbols, with the contravariant index on the first dimension.

inner_product_derivative_matrix(base_point)[source]#

Compute derivative of the inner prod matrix at base point.

The only entry is \(\partial_p g_{pp} = n (2p - 1) / (p^2 (1 - p)^2)\).

Parameters:

base_point (array-like, shape=[…, 1]) – Base point.

Returns:

metric_derivative (array-like, shape=[…, 1, 1, 1]) – Derivative of the inner-product matrix, where the index k of the derivation is last: \(mat_{ijk} = \partial_k g_{ij}\).

jacobian_christoffels(base_point)[source]#

Compute the Jacobian of the Christoffel symbols.

The only entry is \(\partial_p \Gamma^p_{pp} = 1 / (2 p^2) + 1 / (2 (1 - p)^2)\).

Parameters:

base_point (array-like, shape=[…, 1]) – Base point.

Returns:

jac (array-like, shape=[…, 1, 1, 1, 1]) – Jacobian of the Christoffel symbols. \(jac[..., i, j, k, l] = dGamma^i_{jk} / dx_l\)

metric_matrix(base_point)[source]#

Compute the metric matrix at the tangent space at base_point.

Parameters:

base_point (array-like, shape=[…, 1]) – Point representing a binomial distribution.

Returns:

mat (array-like, shape=[…, 1, 1]) – Metric matrix.

geomstats.information_geometry.categorical module#

Statistical Manifold of categorical distributions with the Fisher metric.

Lead author: Alice Le Brigant.

class geomstats.information_geometry.categorical.CategoricalDistributions(dim, equip=True)[source]#

Bases: MultinomialDistributions

Class for the manifold of categorical distributions.

This is the set of n+1-tuples of positive reals that sum up to one, i.e. the n-simplex. Each point is the parameter of a categorical distribution, i.e. gives the probabilities of n different outcomes in a single experiment.

Parameters:
  • dim (int) – Dimension of the manifold of categorical distributions. The number of outcomes is dim + 1.

  • equip (bool) – If True, equip space with default metric.

static default_metric()[source]#

Metric to equip the space with if equip is True.

class geomstats.information_geometry.categorical.CategoricalMetric(space)[source]#

Bases: MultinomialMetric

Class for the Fisher information metric on categorical distributions.

The Fisher information metric on the n-simplex of categorical distributions parameters can be obtained as the pullback metric of the n-sphere using the componentwise square root.

References

[K1989]

R. E. Kass. The Geometry of Asymptotic Inference. Statistical Science, 4(3): 188 - 234, 1989.

geomstats.information_geometry.dirichlet module#

Statistical Manifold of Dirichlet distributions with the Fisher metric.

Lead author: Alice Le Brigant.

class geomstats.information_geometry.dirichlet.DirichletDistributions(dim, equip=True)[source]#

Bases: InformationManifoldMixin, PositiveOrthant

Class for the manifold of Dirichlet distributions.

This is Dirichlet = \((R_+^*)^dim\), the positive quadrant of the dim-dimensional Euclidean space.

Parameters:
  • dim (int) – Dimension of the manifold of Dirichlet distributions.

  • equip (bool) – If True, equip space with default metric.

static default_metric()[source]#

Metric to equip the space with if equip is True.

point_to_pdf(point)[source]#

Compute pdf associated to point.

Compute the probability density function of the Dirichlet distribution with parameters provided by point.

Parameters:

point (array-like, shape=[…, dim]) – Point representing a beta distribution.

Returns:

pdf (function) – Probability density function of the Dirichlet distribution with parameters provided by point.

sample(point, n_samples=1)[source]#

Sample from the Dirichlet distribution.

Sample from the Dirichlet distribution with parameters provided by point. This gives n_samples points in the simplex.

Parameters:
  • point (array-like, shape=[…, dim]) – Point representing a Dirichlet distribution.

  • n_samples (int) – Number of points to sample for each set of parameters in point.

Returns:

samples (array-like, shape=[…, n_samples, dim]) – Sample from the Dirichlet distributions.

class geomstats.information_geometry.dirichlet.DirichletMetric(space)[source]#

Bases: CoordinateRiemannianMetric

Class for the Fisher information metric on Dirichlet distributions.

christoffels(base_point)[source]#

Compute the Christoffel symbols.

Compute the Christoffel symbols of the Fisher information metric:

\[\Gamma_{j k}^i=\frac{1}{2}\left[\frac{d_i L_0}{D}-\delta_{j k} \frac{d_i L_j}{D}-\delta_{i j} \delta_{i k} L_i\right]\]

where

\[d_i=\frac{1}{\psi_1\left(\alpha_i\right)}, \quad L_i=\partial_i \log d_i, \quad L_0=\partial_{\alpha_0} \log d_0, \quad D=d_0-\sum_i d_i\]
Parameters:

base_point (array-like, shape=[…, dim]) – Base point.

Returns:

christoffels (array-like, shape=[…, dim, dim, dim]) – Christoffel symbols, with the contravariant index on the first dimension. \(christoffels[..., i, j, k] = Gamma^i_{jk}\)

References

[LPP2021]

A. Le Brigant, S. C. Preston, S. Puechmorel. Fisher-Rao geometry of Dirichlet Distributions. Differential Geometry and its Applications, 74, 101702, 2021.

injectivity_radius(base_point=None)[source]#

Compute the radius of the injectivity domain.

This is the supremum of radii r for which the exponential map is a diffeomorphism from the open ball of radius r centered at the base point onto its image. In the case of the hyperbolic space, it does not depend on the base point and is infinite everywhere, because of the negative curvature.

Parameters:

base_point (array-like, shape=[…, dim]) – Point on the manifold.

Returns:

radius (array-like, shape=[…,]) – Injectivity radius.

inner_product_derivative_matrix(base_point)[source]#

Compute derivative of the inner prod matrix at base point.

\[\partial_k g_{ij} = \psi''(\alpha_i) \delta_{ij} \delta_{ik} - \psi''\left(\sum_l \alpha_l\right)\]

where \(\psi\) is the digamma function.

Parameters:

base_point (array-like, shape=[…, dim]) – Base point.

Returns:

metric_derivative (array-like, shape=[…, dim, dim, dim]) – Derivative of the inner-product matrix, where the index k of the derivation is last: \(mat_{ijk} = \partial_k g_{ij}\).

jacobian_christoffels(base_point)[source]#

Compute the Jacobian of the Christoffel symbols.

Compute the Jacobian of the Christoffel symbols of the Fisher information metric.

Parameters:

base_point (array-like, shape=[…, dim]) – Base point.

Returns:

jac (array-like, shape=[…, dim, dim, dim, dim]) – Jacobian of the Christoffel symbols. \(jac[..., i, j, k, l] = dGamma^i_{jk} / dx_l\)

metric_matrix(base_point)[source]#

Compute the inner-product matrix.

Compute the inner-product matrix of the Fisher information metric at the tangent space at base point.

Parameters:

base_point (array-like, shape=[…, dim]) – Base point.

Returns:

mat (array-like, shape=[…, dim, dim]) – Inner-product matrix.

class geomstats.information_geometry.dirichlet.DirichletRandomVariable(space)[source]#

Bases: ScipyMultivariateRandomVariable

A Dirichlet random variable.

geomstats.information_geometry.exponential module#

Statistical Manifold of exponential distributions with the Fisher metric.

Lead authors: Jules Deschamps, Tra My Nguyen.

class geomstats.information_geometry.exponential.ExponentialDistributions(equip=True)[source]#

Bases: InformationManifoldMixin, PositiveReals

Class for the manifold of exponential distributions.

This is the parameter space of exponential distributions i.e. the half-line of positive reals.

Parameters:

equip (bool) – If True, equip space with default metric.

static default_metric()[source]#

Metric to equip the space with if equip is True.

point_to_pdf(point)[source]#

Compute pdf associated to point.

Compute the probability density function of the exponential distribution with parameters provided by point.

Parameters:

point (array-like, shape=[…, 1]) – Point representing an exponential distribution (scale).

Returns:

pdf (function) – Probability density function of the exponential distribution with scale parameter provided by point.

sample(point, n_samples=1)[source]#

Sample from the exponential distribution.

Sample from the exponential distribution with parameter provided by point.

Parameters:
  • point (array-like, shape=[…,]) – Point representing an exponential distribution.

  • n_samples (int) – Number of points to sample with each parameter in point.

Returns:

samples (array-like, shape=[…, n_samples]) – Sample from exponential distributions.

class geomstats.information_geometry.exponential.ExponentialDistributionsRandomVariable(space)[source]#

Bases: ScipyUnivariateRandomVariable

An exponential random variable.

class geomstats.information_geometry.exponential.ExponentialMetric(space, signature=None)[source]#

Bases: LogMetric

Class for the Fisher information metric on exponential distributions.

It coincides with the logarithmic metric on the positive reals.

References

[AM1981]

Atkinson, C., & Mitchell, A. F. (1981). Rao’s distance measure. Sankhyā: The Indian Journal of Statistics, Series A, 345-365.

geomstats.information_geometry.fisher_rao_metric module#

Class to implement simply the Fisher-Rao metric on information manifolds.

class geomstats.information_geometry.fisher_rao_metric.FisherRaoMetric(space, support)[source]#

Bases: CoordinateRiemannianMetric

Class to derive the information metric from the pdf in InformationManifoldMixin.

Given a statistical manifold with coordinates \(\theta\), the Fisher information metric is:

\[g_{j k}(\theta)=\int_X \frac{\partial \log p(x, \theta)} {\partial \theta_j}\frac{\partial \log p(x, \theta)} {\partial \theta_k} p(x, \theta) d x\]
space#

Riemannian Manifold for a parametric family of (real) distributions.

Type:

InformationManifold

support#

Left and right bounds for the support of the distribution. But this is just to help integration, bounds should be as large as needed.

Type:

list, shape = (2,)

inner_product_derivative_matrix(base_point)[source]#

Compute the derivative of the inner-product matrix.

Compute the derivative of the inner-product matrix of the Fisher information metric at the tangent space at base point.

\[\partial_{\theta} I(\theta) = \partial_{\theta} \mathbb{E}[YY^T]\]

where,

\[Y = \nabla_{\theta} \log f_{\theta}(x)\]

or, in indicial notation:

\[\partial_k I_{ij} = \int\ \partial_{ki}^2 f\partial_j f \frac{1}{f} + \ \partial_{kj}^2 f\partial_i f \frac{1}{f} - \ \partial_i f \partial_j f \partial_k f \frac{1}{f^2}\]

with \(f = f_{\theta}(x)\)

Parameters:

base_point (array-like, shape=[…, dim]) – Base point.

Returns:

mat (array-like, shape=[…, dim, dim, dim]) – Derivative of the inner-product matrix, where the index k of the derivation is last \(mat_{ijk} = \partial_k g_{ij}\).

metric_matrix(base_point)[source]#

Compute the inner-product matrix.

The Fisher information matrix is noted I in the literature.

Compute the inner-product matrix of the Fisher information metric at the tangent space at base point.

\[I(\theta) = \mathbb{E}[YY^T]\]

where,

\[Y = \nabla_{\theta} \log f_{\theta}(x)\]

After manipulation and in indicial notation

\[I_{ij} = \int \ \partial_{i} f_{\theta}(x)\ \partial_{j} f_{\theta}(x)\ \frac{1}{f_{\theta}(x)}\]
Parameters:

base_point (array-like, shape=[…, dim]) – Base point.

Returns:

metric_mat (array-like, shape=[…, dim, dim]) – Inner-product matrix.

References

[AS1985]

Amari, S (1985) Differential Geometric Methods in Statistics, Berlin, Springer – Verlag.

geomstats.information_geometry.gamma module#

Statistical Manifold of Gamma distributions with the Fisher metric.

A Gamma distribution is commonly parametrized by its shape and rate: point = [kappa, nu], where kappa is the shape parameter, and nu the rate, or 1/scale.

However, information geometry most often works with its shape and mean: point = [kappa, gamma] = [kappa, kappa/nu].

The shape-mean parametrization is the convention we use in this script. All points and all vectors input are assumed to be given in the shape-mean parametrization unless stated otherwise.

ScaledReciprocalDiffeo makes the associated change of variable, either for a point or a vector.

Lead author: Jules Deschamps.

class geomstats.information_geometry.gamma.GammaDistributions(equip=True)[source]#

Bases: InformationManifoldMixin, PositiveOrthant

Class for the manifold of Gamma distributions.

This is \(Gamma = (R_+^*)^2\), the positive quadrant of the 2-dimensional Euclidean space.

static default_metric()[source]#

Metric to equip the space with if equip is True.

static maximum_likelihood_fit(data)[source]#

Estimate parameters from samples.

This is a wrapper around scipy’s maximum likelihood estimator to estimate the parameters of a gamma distribution from samples.

Parameters:

data (list or list of lists/arrays) – Data to estimate parameters from. Lists of different length may be passed.

Returns:

parameter (array-like, shape=[…, 2]) – Estimate of parameter obtained by maximum likelihood.

point_to_pdf(point)[source]#

Compute pdf associated to point.

Compute the probability density function of the Gamma distribution with parameters provided by point.

Parameters:

point (array-like, shape=[…, dim]) – Point representing a Gamma distribution.

Returns:

pdf (function) – Probability density function of the Gamma distribution with parameters provided by point.

sample(point, n_samples=1)[source]#

Sample from the Gamma distribution.

Sample from the Gamma distribution with parameters provided by point. This gives n_samples points.

Parameters:
  • point (array-like, shape=[…, dim]) – Point representing a Gamma distribution.

  • n_samples (int) – Number of points to sample for each set of parameters in point.

Returns:

samples (array-like, shape=[…, n_samples]) – Sample from the Gamma distributions.

class geomstats.information_geometry.gamma.GammaDistributionsRandomVariable(space)[source]#

Bases: ScipyUnivariateRandomVariable

A gamma random variable.

class geomstats.information_geometry.gamma.GammaMetric(space)[source]#

Bases: CoordinateRiemannianMetric

Class for the Fisher information metric on Gamma distributions.

References

[AD2008]

Arwini, K. A., & Dodson, C. T. (2008). Information geometry (pp. 31-54). Springer Berlin Heidelberg.

christoffels(base_point)[source]#

Compute the Christoffel symbols.

Compute the Christoffel symbols of the Fisher information metric. For computation purposes, we replace the value of (gs.polygamma(1, x) - 1/x) by an equivalent (close lower-bound) when it becomes too difficult to compute, as per in [GQ2015].

Parameters:

base_point (array-like, shape=[…, 2]) – Base point.

Returns:

christoffels (array-like, shape=[…, 2, 2, 2]) – Christoffel symbols, with the contravariant index on the first dimension. \(christoffels[..., i, j, k] = Gamma^i_{jk}\)

References

[AD2008]

Arwini, K. A., & Dodson, C. T. (2008). Information geometry (pp. 31-54). Springer Berlin Heidelberg.

[GQ2015]

Guo, B. N., Qi, F., Zhao, J. L., & Luo, Q. M. (2015). Sharp inequalities for polygamma functions. Mathematica Slovaca, 65(1), 103-120.

gaussian_curvature(base_point)[source]#

Compute the Gaussian curvature.

The Gaussian curvature of the Fisher information metric only depends on \(\kappa\):

\[K = \frac{\psi'(\kappa) + \kappa \psi''(\kappa)} {4 (\kappa \psi'(\kappa) - 1)^2}\]

where \(\psi\) is the digamma function.

Parameters:

base_point (array-like, shape=[…, 2]) – Base point.

Returns:

curvature (array-like, shape=[…,]) – Gaussian curvature at base_point.

injectivity_radius(base_point)[source]#

Compute the radius of the injectivity domain.

The space is simply connected, complete and has negative curvature, so it is infinite.

Parameters:

base_point (array-like, shape=[…, 2]) – Point on the manifold.

Returns:

radius (array-like, shape=[…,]) – Injectivity radius.

inner_product_derivative_matrix(base_point)[source]#

Compute derivative of the inner prod matrix at base point.

The non-zero entries are \(\partial_\kappa g_{\kappa\kappa} = \psi''(\kappa) + 1 / \kappa^2\), \(\partial_\kappa g_{\gamma\gamma} = 1 / \gamma^2\) and \(\partial_\gamma g_{\gamma\gamma} = -2 \kappa / \gamma^3\), where \(\psi\) is the digamma function.

Parameters:

base_point (array-like, shape=[…, 2]) – Base point.

Returns:

metric_derivative (array-like, shape=[…, 2, 2, 2]) – Derivative of the inner-product matrix, where the index k of the derivation is last: \(mat_{ijk} = \partial_k g_{ij}\).

jacobian_christoffels(base_point)[source]#

Compute the Jacobian of the Christoffel symbols.

Compute the Jacobian of the Christoffel symbols of the Fisher information metric.

For computation purposes, we replace the value of (gs.polygamma(1, x) - 1/x) and (gs.polygamma(2,x) + 1/x**2) by an equivalent (close bounds) when they become too difficult to compute.

Parameters:

base_point (array-like, shape=[…, 2]) – Base point.

Returns:

jac (array-like, shape=[…, 2, 2, 2, 2]) – Jacobian of the Christoffel symbols. \(jac[..., i, j, k, l] = dGamma^i_{jk} / dx_l\)

References

[GQ2015]

Guo, B. N., Qi, F., Zhao, J. L., & Luo, Q. M. (2015). Sharp inequalities for polygamma functions. Mathematica Slovaca, 65(1), 103-120.

metric_matrix(base_point)[source]#

Compute the inner-product matrix.

Compute the inner-product matrix of the Fisher information metric at the tangent space at base point.

Parameters:

base_point (array-like, shape=[…, 2]) – Base point.

Returns:

mat (array-like, shape=[…, 2, 2]) – Inner-product matrix.

riemann_tensor(base_point)[source]#

Compute Riemannian tensor at base_point.

In dimension two, the curvature is determined by the Gaussian curvature \(K\): \(R(X, Y)Z = K (\langle Y, Z \rangle X - \langle X, Z \rangle Y)\), i.e. \(R_{ijk}^l = K (g_{ki} \delta_j^l - g_{ji} \delta_k^l)\).

Parameters:

base_point (array-like, shape=[…, 2]) – Base point.

Returns:

riemann_curvature (array-like, shape=[…, 2, 2, 2, 2]) – riemann_tensor[…,i,j,k,l] = R_{ijk}^l Riemannian tensor curvature, with the contravariant index on the last dimension.

scalar_curvature(base_point)[source]#

Compute scalar curvature at base_point.

The space is two-dimensional, so the scalar curvature is twice the Gaussian curvature.

Parameters:

base_point (array-like, shape=[…, 2]) – Base point.

Returns:

curvature (array-like, shape=[…,]) – Scalar curvature.

sectional_curvature(tangent_vec_a, tangent_vec_b, base_point)[source]#

Compute the sectional curvature.

In dimension two, the sectional curvature is the Gaussian curvature, whatever the tangent vectors (including collinear ones, for which the general definition is degenerate).

Parameters:
  • tangent_vec_a (array-like, shape=[…, 2]) – Tangent vector at base_point.

  • tangent_vec_b (array-like, shape=[…, 2]) – Tangent vector at base_point.

  • base_point (array-like, shape=[…, 2]) – Point in the manifold.

Returns:

sectional_curvature (array-like, shape=[…,]) – Sectional curvature at base_point.

class geomstats.information_geometry.gamma.ShapeRateGammaDistributions(equip=True)[source]#

Bases: PositiveOrthant

Manifold of Gamma distributions in the shape-rate parametrization.

Points are given by \([\kappa, \nu]\), where \(\kappa\) is the shape parameter and \(\nu\) the rate, or 1/scale. They are mapped to the shape-mean parametrization of GammaDistributions by ScaledReciprocalDiffeo.

Parameters:

equip (bool) – If True, equip space with default metric.

static default_metric()[source]#

Metric to equip the space with if equip is True.

class geomstats.information_geometry.gamma.ShapeRateGammaMetric(space)[source]#

Bases: CoordinatePullbackDiffeoMetric

Fisher information metric on Gamma distributions in shape-rate form.

It is the pullback of GammaMetric through ScaledReciprocalDiffeo.

geomstats.information_geometry.geometric module#

Statistical Manifold of geometric distributions with the Fisher metric.

Lead author: Tra My Nguyen.

class geomstats.information_geometry.geometric.GeometricDistributions(equip=True)[source]#

Bases: InformationManifoldMixin, OpenInterval

Class for the manifold of geometric distributions.

This is the parameter space of geometric distributions i.e. the interval (0, 1).

Parameters:

equip (bool) – If True, equip space with default metric.

static default_metric()[source]#

Metric to equip the space with if equip is True.

point_to_pdf(point)[source]#

Compute pmf associated to point.

Compute the probability mass function of the geometric distribution with parameters provided by point.

Parameters:

point (array-like, shape=[…, 1]) – Point representing an geometric distribution (scale).

Returns:

pdf (function) – Probability mass function of the geometric distribution with scale parameter provided by point.

sample(point, n_samples=1)[source]#

Sample from the geometric distribution.

Sample from the geometric distribution with parameter provided by point.

Parameters:
  • point (array-like, shape=[…, 1]) – Point representing an geometric distribution.

  • n_samples (int) – Number of points to sample with each parameter in point.

Returns:

samples (array-like, shape=[…, n_samples]) – Sample from geometric distributions.

class geomstats.information_geometry.geometric.GeometricDistributionsRandomVariable(space)[source]#

Bases: ScipyUnivariateRandomVariable

A geometric random variable.

pdf(x, point)[source]#

Evaluate the probability density function at x.

Parameters:
  • x (array-like, shape=[n_samples, *support_shape]) – Sample points at which to compute the probability density function.

  • point (array-like, shape=[…, *space.shape]) – Point representing a distribution.

Returns:

pdf_at_x (array-like, shape=[…, n_samples, *support_shape]) – Values of pdf at x for each value of the parameters provided by point.

class geomstats.information_geometry.geometric.GeometricMetric(space)[source]#

Bases: FlatCoordinateMixin, CoordinatePullbackDiffeoMetric

Class for the Fisher information metric on geometric distributions.

It is the pullback of the Euclidean metric on the half-line \((0, \infty)\) through ArtanhSqrtDiffeo. The space is one-dimensional, so the metric is flat.

References

[AM1981]

Atkinson, C., & Mitchell, A. F. (1981). Rao’s distance measure. Sankhyā: The Indian Journal of Statistics, Series A, 345-365.

christoffels(base_point)[source]#

Compute the Christoffel symbols.

The only symbol is \(\Gamma^p_{pp} = -1 / p + 1 / (2 (1 - p))\).

Parameters:

base_point (array-like, shape=[…, 1]) – Base point.

Returns:

christoffels (array-like, shape=[…, 1, 1, 1]) – Christoffel symbols, with the contravariant index on the first dimension.

inner_product_derivative_matrix(base_point)[source]#

Compute derivative of the inner prod matrix at base point.

The only entry is \(\partial_p g_{pp} = (3p - 2) / (p^3 (1 - p)^2)\).

Parameters:

base_point (array-like, shape=[…, 1]) – Base point.

Returns:

metric_derivative (array-like, shape=[…, 1, 1, 1]) – Derivative of the inner-product matrix, where the index k of the derivation is last: \(mat_{ijk} = \partial_k g_{ij}\).

jacobian_christoffels(base_point)[source]#

Compute the Jacobian of the Christoffel symbols.

The only entry is \(\partial_p \Gamma^p_{pp} = 1 / p^2 + 1 / (2 (1 - p)^2)\).

Parameters:

base_point (array-like, shape=[…, 1]) – Base point.

Returns:

jac (array-like, shape=[…, 1, 1, 1, 1]) – Jacobian of the Christoffel symbols. \(jac[..., i, j, k, l] = dGamma^i_{jk} / dx_l\)

metric_matrix(base_point)[source]#

Compute the metric matrix at base_point.

Parameters:

base_point (array-like, shape=[…, 1]) – Point representing a geometric distribution.

Returns:

mat (array-like, shape=[…, 1, 1]) – Metric matrix.

geomstats.information_geometry.multinomial module#

Statistical Manifold of multinomial distributions with the Fisher metric.

Lead author: Alice Le Brigant.

class geomstats.information_geometry.multinomial.MultinomialDistributions(dim, n_draws, equip=True)[source]#

Bases: InformationManifoldMixin, OpenSimplex

Class for the manifold of multinomial distributions.

This is the set of n+1-tuples of positive reals that sum up to one, i.e. the n-simplex. Each point is the parameter of a multinomial distribution, i.e. gives the probabilities of n different outcomes in a single experiment.

Parameters:
  • dim (int) – Dimension of the parameter manifold of multinomial distributions. The number of outcomes is dim + 1.

  • n_draws (int) – Number of draws.

  • equip (bool) – If True, equip space with default metric.

static default_metric()[source]#

Metric to equip the space with if equip is True.

point_to_pdf(point)[source]#

Compute pdf associated to point.

Compute the probability density function of the Multinomial distribution with parameters provided by point.

Parameters:

point (array-like, shape=[…, dim]) – Point representing a beta distribution.

Returns:

pdf (function) – (Discrete) probability density function.

sample(point, n_samples=1)[source]#

Sample from the multinomial distribution.

Sample from the multinomial distribution with parameters provided by point. This gives samples in the simplex.

Parameters:
  • point (array-like, shape=[…, dim + 1]) – Parameters of a multinomial distribution, i.e. probabilities associated to dim + 1 outcomes.

  • n_samples (int) – Number of points to sample with each set of parameters in point.

Returns:

samples (array-like, shape=[…, n_samples, dim + 1]) – Samples from multinomial distributions. Note that this can be of shape [n_points, n_samples, dim + 1] if several points and several samples are provided as inputs.

class geomstats.information_geometry.multinomial.MultinomialMetric(space)[source]#

Bases: PullbackDiffeoMetric

Class for the Fisher information metric on multinomial distributions.

The Fisher information metric on the n-simplex of multinomial distributions parameters can be obtained as the pullback metric of the n-sphere using the componentwise square root.

References

[K1989]

R. E. Kass. The Geometry of Asymptotic Inference. Statistical Science, 4(3): 188 - 234, 1989.

class geomstats.information_geometry.multinomial.MultinomialRandomVariable(space)[source]#

Bases: ScipyMultivariateRandomVariable

A multinomial random variable.

geomstats.information_geometry.poisson module#

Statistical Manifold of Poisson distributions with the Fisher metric.

Lead author: Tra My Nguyen.

class geomstats.information_geometry.poisson.PoissonDistributions(equip=True)[source]#

Bases: InformationManifoldMixin, PositiveReals

Class for the manifold of Poisson distributions.

This is the parameter space of Poisson distributions i.e. the half-line of positive reals.

Parameters:

equip (bool) – If True, equip space with default metric.

static default_metric()[source]#

Metric to equip the space with if equip is True.

point_to_pdf(point)[source]#

Compute pmf associated to point.

Compute the probability mass function of the Poisson distribution with parameters provided by point.

Parameters:

point (array-like, shape=[…, 1]) – Point representing an Poisson distribution (scale).

Returns:

pdf (function) – Probability mass function of the Poisson distribution with scale parameter provided by point.

sample(point, n_samples=1)[source]#

Sample from the Poisson distribution.

Sample from the Poisson distribution with parameter provided by point.

Parameters:
  • point (array-like, shape=[…, 1]) – Point representing an Poisson distribution.

  • n_samples (int) – Number of points to sample with each parameter in point.

Returns:

samples (array-like, shape=[…, n_samples]) – Sample from Poisson distributions.

class geomstats.information_geometry.poisson.PoissonDistributionsRandomVariable(space)[source]#

Bases: ScipyUnivariateRandomVariable

A Poisson random variable.

pdf(x, point)[source]#

Evaluate the probability density function at x.

Parameters:
  • x (array-like, shape=[n_samples, *support_shape]) – Sample points at which to compute the probability density function.

  • point (array-like, shape=[…, *space.shape]) – Point representing a distribution.

Returns:

pdf_at_x (array-like, shape=[…, n_samples, *support_shape]) – Values of pdf at x for each value of the parameters provided by point.

class geomstats.information_geometry.poisson.PoissonMetric(space)[source]#

Bases: PowerMetric

Class for the Fisher information metric on Poisson distributions.

It coincides with the power-Euclidean metric with power 1/2 on the positive reals.

References

[AM1981]

Atkinson, C., & Mitchell, A. F. (1981). Rao’s distance measure. Sankhyā: The Indian Journal of Statistics, Series A, 345-365.

Module contents#