Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated docs #119

Merged
merged 1 commit into from
Dec 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/src/introToRiemannianGeometry.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ The ‘centrality’ of this mean among a wide family of divergence-based means
can be appreciated in Fig. 4 of Cichocki et *al.* (2015)[🎓](@ref).

The geometric mean ``G`` of two matrices ``P`` and ``Q`` is
denoted ``\gamma(P, Q, 1/2)``. Currently it is an object
denoted ``\gamma(P, Q, \frac{1}{2})``. Currently it is an object
of intense study because of its interesting mathematical properties.
For instance,
- it is the unique solution to Riccati equation ``GQ^{-1}G=P``
Expand All @@ -246,7 +246,7 @@ We denote the Fisher geodesic equation as ``\gamma(P, Q, a)``.
Note that ``\gamma(I, P, a)=P^a`` and ``\gamma(P, I, a)=P^{b}``, where ``b=1-a``.

Fisher geodesic equation verifies ``\gamma(P, Q, a)=\gamma(Q, P, b)``
and ``(\gamma(P, Q, a))^{-1}=\gamma(P{-1}, Q{-1}, a)``.
and ``(\gamma(P, Q, a))^{-1}=\gamma(P^{-1}, Q^{-1}, a)``.

An interesting property of the Fisher metric is that using its
geodesic equation we can extrapolate positive matrices, always
Expand All @@ -270,25 +270,25 @@ The family of power means ``G`` with parameter ``p`` satisfies equation

``G=\sum_{i=1}^{k}w_i\gamma(G, P, p)``,

where``𝛾(G, P, p)`` is the Fisher geodesic equation we have discussed here above talking about the [Fisher](@ref) metric. In particular:
where``\gamma(G, P, p)`` is the Fisher geodesic equation we have discussed here above talking about the [Fisher](@ref) metric. In particular:

- with ``p=-1`` this is the harmonic mean (see the [inverse Euclidean](@ref) metric)
- with ``p=+1`` this is the arithmetic mean (see the [Euclidean](@ref) metric)
- at the limit of ``p`` evaluated at zero from both side this is the geometric mean (see the [Fisher](@ref) metric).
* with ``p=-1`` this is the harmonic mean (see the [inverse Euclidean](@ref) metric)
* with ``p=+1`` this is the arithmetic mean (see the [Euclidean](@ref) metric)
* at the limit of ``p`` evaluated at zero from both side this is the geometric mean (see the [Fisher](@ref) metric).

Thus, the family of power means continuously interpolate between the arithmetic and harmonic mean passing through the the geometric mean.

Power means are the unique positive definite solution of (Yamazaki, 2019)[🎓](@ref)

``\sum_{i=1}^{k}w_i\big(G^{-1/2} P_i G^{-1/2}\big)^p=I.``.
``\sum_{i=1}^{k}w_i\big(G^{-1/2} P_i G^{-1/2}\big)^p=I``.

All power means enjoy the congruence invariance (hence the rotation invariance),
but only the geometric mean enjoy also the inversion invariance.

The power mean with ``p=\frac{1}{2}`` is the solution of the [Fréchet mean](@ref)
problem using the following divergence (Bhatia, Gaubert and Jain, 2019)[🎓](@ref)

``δ^2(P,Q)=\textrm{tr}(P+Q)-2\textrm{tr}\gamma(G, P, 1/2) = \textrm{tr}(\textrm{arithm. mean}(P, Q)) – \textrm{tr}(\textrm{geom. mean}(P, Q)).``
``δ^2(P,Q)=\textrm{tr}(P+Q)-2\textrm{tr}\gamma(G, P, \frac{1}{2}) = \textrm{tr}(\textrm{arithm. mean}(P, Q)) – \textrm{tr}(\textrm{geom. mean}(P, Q)).``



Expand Down
90 changes: 45 additions & 45 deletions src/riemannianGeometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1517,50 +1517,50 @@ end # function
⏩=true >)
```

**alias**: `gmean`
**alias**: `gmean`

Given a 1d array ``𝐏={P_1,...,P_k}`` of ``k`` positive definite matrices of
[ℍVector type](@ref) or diagonal matrices of [𝔻Vector type](@ref)
and optional non-negative real weights vector ``w={w_1,...,w_k}``,
return the 3-tuple ``(G, iter, conv)``, where ``G`` is the mean according
to the [Fisher](@ref) metric and ``iter``, ``conv`` are the number of iterations
and convergence attained by the algorithm.
Mean ``G`` is the unique positive definite matrix satisfying
Given a 1d array ``𝐏={P_1,...,P_k}`` of ``k`` positive definite matrices of
[ℍVector type](@ref) or diagonal matrices of [𝔻Vector type](@ref)
and optional non-negative real weights vector ``w={w_1,...,w_k}``,
return the 3-tuple ``(G, iter, conv)``, where ``G`` is the mean according
to the [Fisher](@ref) metric and ``iter``, ``conv`` are the number of iterations
and convergence attained by the algorithm.
Mean ``G`` is the unique positive definite matrix satisfying

``\\sum_{i=1}^{k}w_i\\textrm{log}\\big(G^{-1/2} P_i G^{-1/2}\\big)=0.``

For estimating it, this function implements the well-known gradient descent
algorithm, but with an exponential decaying step size ``ς``, yielding iterations
For estimating it, this function implements the well-known gradient descent
algorithm, but with an exponential decaying step size ``ς``, yielding iterations

``G ←G^{1/2}\\textrm{exp}\\big(ς\\sum_{i=1}^{k}w_i\\textrm{log}(G^{-1/2} P_i G^{-1/2})\\big)G^{1/2}.``

If you don't pass a weight vector with *<optional keyword argument>* ``w``,
return the *unweighted geometric mean*.

If *<optional keyword argument>* `✓w=true` (default), the weights are
normalized so as to sum up to 1, otherwise they are used as they are passed
and should be already normalized. This option is provided to allow
calling this function repeatedly without normalizing the same weights
vector each time.

The following are more *<optional keyword arguments*>:
- `init` is a matrix to be used as initialization for the mean. If no matrix is provided, the [log Euclidean](@ref) mean will be used,
- `tol` is the tolerance for the convergence (see below).
- `maxiter` is the maximum number of iterations allowed
- if `verbose`=true, the convergence attained at each iteration and the step size ``ς`` is printed. Also, a *warning* is printed if convergence is not attained.
- if ⏩=true the iterations are multi-threaded (see below).
- if `adaptStepSize`=false the step size `ς` is fixed to 1 at all iterations.

If the input is a 1d array of ``k`` real positive definite diagonal matrices
the solution is available in closed-form as the log Euclidean
mean, hence the *<optional keyword arguments*> `init`, `tol` and `verbose`
have no effect and return the 3-tuple ``(G, 1, 0)``.
See the [log Euclidean](@ref) metric.
If you don't pass a weight vector with *<optional keyword argument>* ``w``,
return the *unweighted geometric mean*.

If *<optional keyword argument>* `✓w=true` (default), the weights are
normalized so as to sum up to 1, otherwise they are used as they are passed
and should be already normalized. This option is provided to allow
calling this function repeatedly without normalizing the same weights
vector each time.

The following are more *<optional keyword arguments*>:
- `init` is a matrix to be used as initialization for the mean. If no matrix is provided, the [log Euclidean](@ref) mean will be used,
- `tol` is the tolerance for the convergence (see below).
- `maxiter` is the maximum number of iterations allowed
- if `verbose`=true, the convergence attained at each iteration and the step size ``ς`` is printed. Also, a *warning* is printed if convergence is not attained.
- if ⏩=true the iterations are multi-threaded (see below).
- if `adaptStepSize`=false the step size `ς` is fixed to 1 at all iterations.

If the input is a 1d array of ``k`` real positive definite diagonal matrices
the solution is available in closed-form as the log Euclidean
mean, hence the *<optional keyword arguments*> `init`, `tol` and `verbose`
have no effect and return the 3-tuple ``(G, 1, 0)``.
See the [log Euclidean](@ref) metric.

!!! note "Nota Bene"
[Multi-threading](https://docs.julialang.org/en/v1/manual/parallel-computing/#Multi-Threading-(Experimental)-1)
is automatically disabled if Julia is instructed to use only one thread.
See [Threads](@ref).
!!! note "Nota Bene"
[Multi-threading](https://docs.julialang.org/en/v1/manual/parallel-computing/#Multi-Threading-(Experimental)-1)
is automatically disabled if Julia is instructed to use only one thread.
See [Threads](@ref).

In normal circumstances this algorithm converges monothonically.
If the algorithm diverges and `verbose` is true a **warning** is printed
Expand All @@ -1577,12 +1577,12 @@ end # function
norm of the satisfying matrix equation divided by the number of elements
to vanish for about half the significant digits.

**See**: [Fisher](@ref) metric.
**See**: [Fisher](@ref) metric.

**See also**: [`geometricpMean`](@ref), [`powerMean`](@ref),
**See also**: [`geometricpMean`](@ref), [`powerMean`](@ref),
[`wasMean`](@ref), [`logdet0Mean`](@ref), [`mean`](@ref).

## Examples
## Examples
using LinearAlgebra, PosDefManifold
# Generate a set of 4 random 3x3 SPD matrices
Pset=randP(3, 4) # or, using unicode: 𝐏=randP(3, 4)
Expand Down Expand Up @@ -1717,12 +1717,12 @@ gMean=geometricMean
vector each time.

The following are more *<optional keyword arguments*>:
- `init` is a matrix to be used as initialization for the mean. If no matrix is provided, the [log Euclidean](@ref) mean will be used,
- `tol` is the tolerance for the convergence (see below).
- `maxiter` is the maximum number of iterations allowed.
- if `adaptStepSize`=true (default) the step size ``ς`` for the gradient descent is adapted at each iteration (see below).
- if `verbose`=true, the step-size and convergence attained at each iteration is printed. Also, a *warning* is printed if convergence is not attained.
- if ⏩=true the iterations are multi-threaded (see below).
* `init` is a matrix to be used as initialization for the mean. If no matrix is provided, the [log Euclidean](@ref) mean will be used,
* `tol` is the tolerance for the convergence (see below).
* `maxiter` is the maximum number of iterations allowed.
* if `adaptStepSize`=true (default) the step size ``ς`` for the gradient descent is adapted at each iteration (see below).
* if `verbose`=true, the step-size and convergence attained at each iteration is printed. Also, a *warning* is printed if convergence is not attained.
* if ⏩=true the iterations are multi-threaded (see below).

!!! note "Nota Bene"
[Multi-threading](https://docs.julialang.org/en/v1/manual/parallel-computing/#Multi-Threading-(Experimental)-1)
Expand Down