pytransform3d.uncertainty
.frechet_mean#
- pytransform3d.uncertainty.frechet_mean(samples, mean0, exp, log, inv, concat_one_to_one, concat_many_to_one, n_iter=20)[source]#
Compute the Fréchet mean of samples on a smooth Riemannian manifold.
The mean is computed with an iterative optimization algorithm [1] [2]:
For a set of samples \(\{x_1, \ldots, x_n\}\), we initialize the estimated mean \(\bar{x}_0\), e.g., as \(x_1\).
For a fixed number of steps \(K\), in each iteration \(k\) we improve the estimation of the mean by
Computing the distance of each sample to the current estimate of the mean in tangent space with \(d_{i,k} \leftarrow \log (x_i \cdot \bar{x}_k^{-1})\).
Updating the estimate of the mean with \(\bar{x}_{k+1} \leftarrow \exp(\frac{1}{N}\sum_i d_{i,k}) \cdot \bar{x}_k\).
Return \(\bar{x}_K\).
- Parameters:
- samplesarray-like, shape (n_samples, …)
Samples on a smooth Riemannian manifold.
- mean0array-like, shape (…)
Initial guess for the mean on the manifold.
- expcallable
Exponential map from the tangent space to the manifold.
- logcallable
Logarithmic map from the manifold to the tangent space.
- invcallable
Computes the inverse of an element on the manifold.
- concat_one_to_onecallable
Concatenates elements on the manifold.
- concat_many_to_onecallable
Concatenates multiple elements on the manifold to one element on the manifold.
- n_iterint, optional (default: 20)
Number of iterations of the optimization algorithm.
- Returns:
- meanarray, shape (…)
Fréchet mean on the manifold.
- mean_diffsarray, shape (n_samples, n_tangent_space_components)
Differences between the mean and the samples in the tangent space. These can be used to compute the covariance. They are returned to avoid recomputing them.
See also
estimate_gaussian_rotation_matrix_from_samples
Uses the Frechet mean to compute the mean of a Gaussian distribution over rotations.
estimate_gaussian_transform_from_samples
Uses the Frechet mean to compute the mean of a Gaussian distribution over transformations.
References
[1]Fréchet, M. (1948). Les éléments aléatoires de nature quelconque dans un espace distancié. Annales de l’Institut Henri Poincaré, 10(3), 215–310.
[2]Pennec, X. (2006). Intrinsic Statistics on Riemannian Manifolds: Basic Tools for Geometric Measurements. J Math Imaging Vis 25, 127-154. https://doi.org/10.1007/s10851-006-6228-4