Tangent space models
One of the more popular methods of statistical modeling on manifolds is selecting a point $p$ on the manifold $\mathcal M$ (for example Riemannian center of mass of data points), transforming all point to the tangent space $T_p\mathcal M$ at that point, and using traditional linear models in that tangent space. Tangent space Principal Component Analysis is a popular example of this kind of modeling. The example below demonstrates how to build and use such model.
using Manifolds, MultivariateStats
M = Sphere(2)
pts = [project(M, randn(3)) for _ in 1:100]
m = mean(M, pts)
logs = log.(Ref(M), Ref(m), pts)
basis = DefaultOrthonormalBasis()
coords = map(X -> get_coordinates(M, m, X, basis), logs)
coords_red = reduce(hcat, coords)
z = zeros(manifold_dimension(M)))
model = fit(PCA, coords_red; maxoutdim=1, mean=z)
X = get_vector(M, m, reconstruct(model, [1.0]), basis)The code performs the following steps:
- Creating random data
pts. - Computing Riemannian center of mass
mofpts. - Transforming data to the tangent space at
musing the logarithmic map. - Selecting a
basisof the tangent space atmin which the points will be represented. - Computing coordinates of tangent vectors in said basis.
- Transforming a vector of vectors of coordinates into a matrix
coords_red. - Fitting an ordinary PCA model to the matrix
coords_red. Zero mean chosen, and the first principal direction is to be computed (themaxoutdimargument). - The first principal component is converted into a tangent vector
X.
The same general procedure can be applied to other tangent space models by replacing steps 7 and 8.