The Riemannian median can be defined similarly to the mean, the Riemannian center of mass. We compute for a matrix of m x n
points m
medians in parallel, each consisting of n
points. The median of one such set is defined as a (not necessarily unique)
minimizer of
For this implementation one can further compute a weighted mean, by introducing
the summands . The stopping criterion is a functional
based on the currend iterate, the last iterate and the number of iterations,
where usually a maximum iterations number and a minimial change
(of ) is used (see stopCritMaxIterEpsilonCreator
).
The algorithm follows [1,2] using a subgradient descent algorithm.
Matlab Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
% median(x) calculates the m medians of x ([.,m,n])
% of the input data with a gradient descent algorithm.
% This implementation is based on
%
% B. Afsari, Riemannian Lp center of mass: Existence,
% uniqueness, and convexity,
% Proc. AMS 139(2), pp.655673, 2011.
% and adapted to the median defined in
% P. T. Fletcher, S. Venkatasubramanian, and S. Joshi:
% The geometric median on Riemannian manifolds with
% application to robust atlas estimation.
% NeuroImage. 45 S143?S152
%
% INPUT
% x : m x n Data points ([this.Itemsize,m,n]) to compute
% m means of n points each, pp.
% OUTPUT
% y : m data points of the medians calculated
%
% OPTIONAL
% 'Weights' : (1/n*ones([m,n]) 1xn or mxn weights for the mean
% the first case uses the same weights for all means
% 'InitVal' : m Initial Data points for the gradient descent
% 'MaxIterations': (50) Maximal Number of Iterations
% 'Epsilon' : (10^(5)) Maximal change before stopping
% 
% Manifoldvalued Image Restoration Toolbox 1.0
% J. Persch, R. Bergmann 20150724  20180217
See also
References

Afsari, B (2011). Riemannian \(L^p\)center of mass: Existence, uniqueness, and convexity. Proceedings of the American Mathematical Society. 139 655–73
@article{Af11, title = { {R}iemannian \({L}^p\) center of mass: Existence, uniqueness, and convexity}, author = {Afsari, B.}, journal = {Proceedings of the American Mathematical Society}, volume = {139}, number = {2}, pages = {655673}, year = {2011}, doi = {10.1090/S000299392010105415} }

Fletcher, P T, Venkatasubramanian, S and Joshi, S (2009). The geometric meadian on Riemannian manifolds with application to
robust atlas estimation. NeuroImage. 45 S143–S152
One of the primary goals of computational anatomy is the statistical analysis of anatomical variability in large populations of images. The study of anatomical shape is inherently related to the construction of transformations of the underlying coordinate space, which map one anatomy to another. It is now well established that representing the geometry of shapes or images in Euclidian spaces undermines our ability to represent natural variability in populations. In our previous work we have extended classical statistical analysis techniques, such as averaging, principal components analysis, and regression, to Riemannian manifolds, which are more appropriate representations for describing anatomical variability. In this paper we extend the notion of robust estimation, a well established and powerful tool in traditional statistical analysis of Euclidian data, to manifoldvalued representations of anatomical variability. In particular, we extend the geometric median, a classic robust estimator of centrality for data in Euclidean spaces. We formulate the geometric median of data on a Riemannian manifold as the minimizer of the sum of geodesic distances to the data points. We prove existence and uniqueness of the geometric median on manifolds with nonpositive sectional curvature and give sufficient conditions for uniqueness on positively curved manifolds. Generalizing the Weiszfeld procedure for finding the geometric median of Euclidean data, we present an algorithm for computing the geometric median on an arbitrary manifold. We show that this algorithm converges to the unique solution when it exists. In this paper we exemplify the robustness of the estimation technique by applying the procedure to various manifolds commonly used in the analysis of medical images. Using this approach, we also present a robust brain atlas estimation technique based on the geometric median in the space of deformable images.@article{FVJ09, author = {Fletcher, P. T. and Venkatasubramanian, S. and Joshi, S.}, title = {The geometric meadian on {R}iemannian manifolds with application to robust atlas estimation}, journal = {NeuroImage}, volume = {45}, number = {1, Supplement 1}, pages = {S143S152}, year = {2009}, doi = {10.1016/j.neuroimage.2008.10.052} }