geomstats.information_geometry.normal package#
Submodules#
geomstats.information_geometry.normal.centered module#
Information manifold of centered multivariate normal distributions.
Lead authors: Antoine Collas, Alice Le Brigant.
- class geomstats.information_geometry.normal.centered.CenteredNormalDistributions(sample_dim, equip=True)[source]#
Bases:
InformationManifoldMixin,SPDMatricesClass for the manifold of centered multivariate normal distributions.
This is the class for multivariate normal distributions with zero mean. Each distribution is represented by its covariance matrix, i.e. a symmetric positive-definite matrix of size \(sample\_dim\).
- Parameters:
sample_dim (int) – Dimension of the sample space of the multivariate normal distribution.
- point_to_pdf(point)[source]#
Compute pdf associated to point.
- Parameters:
point (array-like, shape=[…, sample_dim, sample_dim]) – Symmetric positive definite matrix representing the covariance matrix of a multivariate normal distribution with zero mean.
- Returns:
pdf (function) – Probability density function of the centered multivariate normal distributions with covariance matrices provided by point.
- sample(point, n_samples=1)[source]#
Sample from a centered multivariate normal distribution.
- Parameters:
point (array-like, shape=[…, sample_dim, sample_dim]) – Symmetric positive definite matrix representing the covariance matrix of a multivariate normal distribution with zero mean.
n_samples (int) – Number of points to sample with each covariance matrix in point.
- Returns:
samples (array-like, shape=[…, n_samples, sample_dim]) – Sample from centered multivariate normal distributions.
- class geomstats.information_geometry.normal.centered.CenteredNormalMetric(space)[source]#
Bases:
objectClass for the Fisher information metric of centered normal distributions.
Bases:
ScipyMultivariateRandomVariableA multivariate normal random variable with zero mean.
geomstats.information_geometry.normal.diagonal module#
Information manifold of diagonal multivariate normal distributions.
Lead authors: Antoine Collas, Alice Le Brigant.
- class geomstats.information_geometry.normal.diagonal.DiagonalNormalDistributions(sample_dim, equip=True)[source]#
Bases:
InformationManifoldMixin,VectorSpaceOpenSetClass for the manifold of diagonal multivariate normal distributions.
This is the class for multivariate normal distributions with diagonal covariance matrices. Each distribution is represented by a vector of size \(2 * sample\_dim\) where the first \(sample\_dim\) elements contain the mean vector and the \(sample\_dim\) last elements contain the diagonal of the covariance matrix.
- Parameters:
sample_dim (int) – Dimension of the sample space of the multivariate normal distribution.
- belongs(point, atol=1e-08)[source]#
Evaluate if the point belongs to the manifold.
- Parameters:
point (array-like, shape=[…, 2 * sample_dim]) – Point to test. First \(sample\_dim\) elements contain the mean vector and the last \(sample\_dim\) elements contain the diagonal of the covariance matrix.
- Returns:
belongs (array-like, shape=[…,]) – Boolean evaluating if point belongs to the space.
- point_to_pdf(point)[source]#
Compute pdf associated to point.
- Parameters:
point (array-like, shape=[…, 2 * sample_dim]) – Point representing a probability distribution. First \(sample\_dim\) elements contain the mean vector and the last \(sample\_dim\) elements contain the diagonal of the covariance matrix.
- Returns:
pdf (function) – Probability density function of the normal distribution with parameters provided by point.
- projection(point)[source]#
Project a point on the manifold.
Floor the eigenvalues of the diagonal covariance matrix to gs.atol.
- Parameters:
point (array-like, shape=[…, 2 * sample_dim]) – Point to project. First \(sample\_dim\) elements contain the mean vector and the last \(sample\_dim\) elements contain the diagonal of the covariance matrix.
- Returns:
projected (array-like, shape=[…, 2 * sample_dim]) – Point containing means and diagonals of covariance matrices.
- random_point(n_samples=1)[source]#
Generate random parameters of multivariate diagonal normal distributions.
- Parameters:
n_samples (int) – Number of samples.
- Returns:
samples (array-like, shape=[…, 2 * sample_dim]) – Sample of points representing multivariate diagonal normal distributions. First \(sample\_dim\) elements contain the mean vector and the last \(sample\_dim\) elements contain the diagonal of the covariance matrix.
- sample(point, n_samples=1)[source]#
Sample from the diagonal multivariate normal distribution.
- Parameters:
point (array-like, shape=[…, 2 * sample_dim]) – Point on the manifold. First \(sample\_dim\) elements contain the mean vector and the last \(sample\_dim\) elements contain the diagonal of the covariance matrix.
n_samples (int) – Number of points to sample with each pair of parameters in point.
- Returns:
samples (array-like, shape=[…, n_samples, sample_dim]) – Sample from multivariate normal distributions.
- class geomstats.information_geometry.normal.diagonal.DiagonalNormalDistributionsRandomVariable(space)[source]#
Bases:
ScipyMultivariateRandomVariableA diagonal multivariate normal random variable.
- class geomstats.information_geometry.normal.diagonal.DiagonalNormalMetric(space)[source]#
Bases:
RiemannianMetricClass for the Fisher information metric of diagonal normal distributions.
- exp(tangent_vec, base_point)[source]#
Compute the Riemannian exponential.
- Parameters:
tangent_vec (array-like, shape=[…, 2 * sample_dim]) – Tangent vector at the base point.
base_point (array-like, shape=[…, 2 * sample_dim]) – Point.
- Returns:
end_point (array-like, shape=[…, 2 * sample_dim]) – Point reached by the geodesic starting from base_point with initial velocity tangent_vec.
- injectivity_radius(base_point=None)[source]#
Compute the radius of the injectivity domain.
- Parameters:
base_point (array-like, shape=[…, 2 * sample_dim]) – Point on the manifold.
- Returns:
radius (array-like, shape=[…,]) – Injectivity radius.
- inner_product(tangent_vec_a, tangent_vec_b, base_point)[source]#
Inner product between two tangent vectors at a base point.
- Parameters:
tangent_vec_a (array-like, shape=[…, 2 * sample_dim]) – Tangent vector at base point.
tangent_vec_b (array-like, shape=[…, 2 * sample_dim]) – Tangent vector at base point.
base_point (array-like, shape=[…, 2 * sample_dim]) – Base point.
- Returns:
inner_product (array-like, shape=[…,]) – Inner-product.
- log(point, base_point)[source]#
Compute Riemannian logarithm of a point wrt a base point.
- Parameters:
point (array-like, shape=[…, 2 * sample_dim]) – Point.
base_point (array-like, shape=[…, 2 * sample_dim]) – Point.
- Returns:
log (array-like, shape=[…, 2 * sample_dim]) – Tangent vector at the base point equal to the Riemannian logarithm of point at the base point.
geomstats.information_geometry.normal.general module#
Information manifold of general multivariate normal distributions.
Lead authors: Antoine Collas, Alice Le Brigant.
- class geomstats.information_geometry.normal.general.GeneralNormalDistributions(sample_dim, equip=True)[source]#
Bases:
InformationManifoldMixin,ProductManifoldClass for the manifold of multivariate normal distributions.
This is the class for multivariate normal distributions on the Euclidean space. Each distribution is represented by the concatenation of its mean vector and its covariance matrix reshaped in a vector of size \(sample\_dim ^ 2\).
- Parameters:
sample_dim (int) – Dimension of the sample space of the multivariate normal distribution.
- point_to_pdf(point)[source]#
Compute pdf associated to point.
- Parameters:
point (array-like, shape=[…, sample_dim + sample_dim * 2]*) – Point representing a multivariate normal distribution. First \(sample\_dim\) elements contain the mean vector and the last \(sample\_dim ^ 2\) elements contain the covariance matrix row by row.
- Returns:
pdf (function) – Probability density function of the multivariate normal distributions with parameters provided by point.
- sample(point, n_samples=1)[source]#
Sample from a multivariate normal distribution.
- Parameters:
point (array-like, shape=[…, sample_dim + sample_dim * 2]*) – Point representing a multivariate normal distribution. First \(sample\_dim\) elements contain the mean vector and the last \(sample\_dim ^ 2\) elements contain the covariance matrix row by row.
n_samples (int) – Number of points to sample with each parameter in point.
- Returns:
samples (array-like, shape=[…, n_samples, sample_dim]) – Sample from multivariate normal distributions.
- class geomstats.information_geometry.normal.general.MultivariateNormalDistributionsRandomVariable(space)[source]#
Bases:
ScipyMultivariateRandomVariableA multivariate normal random variable.
geomstats.information_geometry.normal.univariate module#
Information manifold of univariate normal distributions.
Lead authors: Antoine Collas, Alice Le Brigant.
- class geomstats.information_geometry.normal.univariate.UnivariateNormalDistributions(equip=True)[source]#
Bases:
InformationManifoldMixin,PoincareHalfSpaceClass for the manifold of univariate normal distributions.
This is the upper half-plane.
- point_to_pdf(point)[source]#
Compute pdf associated to point.
Compute the probability density function of the normal distribution with parameters provided by point.
- Parameters:
point (array-like, shape=[…, 2]) – Point representing a normal distribution (mean and scale).
- Returns:
pdf (function) – Probability density function of the normal distribution with parameters provided by point.
- sample(point, n_samples=1)[source]#
Sample from the normal distribution.
Sample from the normal distribution with parameters provided by point.
- Parameters:
point (array-like, shape=[…, 2]) – Point representing a normal distribution (mean and scale).
n_samples (int) – Number of points to sample with each pair of parameters in point.
- Returns:
samples (array-like, shape=[…, n_samples]) – Sample from normal distributions.
- class geomstats.information_geometry.normal.univariate.UnivariateNormalDistributionsRandomVariable(space)[source]#
Bases:
ScipyUnivariateRandomVariableA univariate normal random variable.
- class geomstats.information_geometry.normal.univariate.UnivariateNormalMetric(space)[source]#
Bases:
CoordinatePullbackDiffeoMetricClass for the Fisher information metric on univariate normal distributions.
This is the pullback of twice the metric of the Poincare upper half-plane by the diffeomorphism \((mean, std) -> (mean / \sqrt{2}, std)\).
- christoffels(base_point)[source]#
Compute the Christoffel symbols.
The nonzero symbols are \(\Gamma^{\mu}_{\mu\sigma} = -1 / \sigma\), \(\Gamma^{\sigma}_{\mu\mu} = 1 / (2 \sigma)\) and \(\Gamma^{\sigma}_{\sigma\sigma} = -1 / \sigma\).
- Parameters:
base_point (array-like, shape=[…, 2]) – Point representing a normal distribution (mean and scale).
- Returns:
christoffels (array-like, shape=[…, 2, 2, 2]) – Christoffel symbols, with the contravariant index on the first dimension.
- static inner_product_derivative_matrix(base_point)[source]#
Compute derivative of the inner prod matrix at base point.
The only nonzero entries are \(\partial_{\sigma} g_{\mu\mu} = -2 / \sigma^3\) and \(\partial_{\sigma} g_{\sigma\sigma} = -4 / \sigma^3\).
- Parameters:
base_point (array-like, shape=[…, 2]) – Point representing a normal distribution (mean and scale).
- 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.
The symbols only depend on \(\sigma\), as \(1 / \sigma\).
- Parameters:
base_point (array-like, shape=[…, 2]) – Point representing a normal distribution (mean and scale).
- Returns:
jac (array-like, shape=[…, 2, 2, 2, 2]) – Jacobian of the Christoffel symbols. \(jac[..., i, j, k, l] = dGamma^i_{jk} / dx_l\)
- static metric_matrix(base_point)[source]#
Compute the metric matrix at the tangent space at base_point.
- Parameters:
base_point (array-like, shape=[…, 2]) – Point representing a normal distribution (mean and scale).
- Returns:
mat (array-like, shape=[…, 2, 2]) – Metric matrix.
- scalar_curvature(base_point=None)[source]#
Compute the scalar curvature.
It is twice the constant sectional curvature, i.e. \(-1\).
- Parameters:
base_point (array-like, shape=[…, 2]) – Point representing a normal distribution (mean and scale).
- Returns:
scalar_curvature (array-like, shape=[…,]) – Scalar curvature at base_point.
- sectional_curvature(tangent_vec_a, tangent_vec_b, base_point=None)[source]#
Compute the sectional curvature.
In the literature sectional curvature is noted K.
For two orthonormal tangent vectors \(x,y\) at a base point, the sectional curvature is defined by \(K(x,y) = <R(x, y)x, y>\).
For non-orthonormal vectors, it is \(K(x,y) = <R(x, y)y, x> / (<x, x><y, y> - <x, y>^2)\).
sectional_curvature(X, Y, P) = K(X,Y) where X, Y are tangent vectors at base point P.
The information manifold of univariate normal distributions has constant sectional curvature given by \(K = - 1/2\).
- 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.
Module contents#
Information manifolds of normal distributions.
Lead authors: Antoine Collas, Alice Le Brigant.
- class geomstats.information_geometry.normal.NormalDistributions(sample_dim, distribution_type='general', equip=True)[source]#
Bases:
objectClass for the normal distributions.
This class is a common interface to the following different situations:
univariate normal distributions
centered multivariate normal distributions
multivariate normal distributions with diagonal covariance matrix
general multivariate normal distributions
- Parameters:
sample_dim (int) – Dimension of the sample space of the normal distribution.
distribution_type (str, {‘centered’, ‘diagonal’, ‘general’}) – Type of distributions.