Home > manopt > manifolds > multinomial > multinomialfactory.m

# multinomialfactory

## PURPOSE

Manifold of n-by-m column-stochastic matrices with positive entries.

## SYNOPSIS

function M = multinomialfactory(n, m)

## DESCRIPTION

``` Manifold of n-by-m column-stochastic matrices with positive entries.

function M = multinomialfactory(n)
function M = multinomialfactory(n, m)

The returned structure M is a Manopt manifold structure to optimize over
the set of n-by-m matrices with (strictly) positive entries and such that
the entries of each column sum to one. By default, m = 1.

The metric imposed on the manifold is the Fisher metric such that
the set of n-by-m column-stochastic matrices (aka the multinomial manifold)
is a Riemannian submanifold of the space of n-by-m matrices. Also it
should be noted that the retraction operation that we define
is first order and as such the checkhessian tool cannot verify
the slope correctly.

The file is based on developments in the research paper
Y. Sun, J. Gao, X. Hong, B. Mishra, and B. Yin,
"Heterogeneous tensor decomposition for clustering via manifold
optimization", arXiv:1504.01777, 2015.

Link to the paper: http://arxiv.org/abs/1504.01777.

Please cite the Manopt paper as well as the research paper:
@Article{sun2015multinomial,
author  = {Y. Sun and J. Gao and X. Hong and B. Mishra and B. Yin},
title   = {Heterogeneous Tensor Decomposition for Clustering via Manifold Optimization},
journal = {IEEE Transactions on Pattern Analysis and Machine Intelligence},
year    = {2016},
volume  = {38},
number  = {3},
pages   = {476--489},
doi     = {10.1109/TPAMI.2015.2465901}
}```

## CROSS-REFERENCE INFORMATION

This function calls:
• hashmd5 Computes the MD5 hash of input data.
• matrixlincomb Linear combination function for tangent vectors represented as matrices.
This function is called by:

## SOURCE CODE

```0001 function M = multinomialfactory(n, m)
0002 % Manifold of n-by-m column-stochastic matrices with positive entries.
0003 %
0004 % function M = multinomialfactory(n)
0005 % function M = multinomialfactory(n, m)
0006 %
0007 % The returned structure M is a Manopt manifold structure to optimize over
0008 % the set of n-by-m matrices with (strictly) positive entries and such that
0009 % the entries of each column sum to one. By default, m = 1.
0010 %
0011 % The metric imposed on the manifold is the Fisher metric such that
0012 % the set of n-by-m column-stochastic matrices (aka the multinomial manifold)
0013 % is a Riemannian submanifold of the space of n-by-m matrices. Also it
0014 % should be noted that the retraction operation that we define
0015 % is first order and as such the checkhessian tool cannot verify
0016 % the slope correctly.
0017 %
0018 % The file is based on developments in the research paper
0019 % Y. Sun, J. Gao, X. Hong, B. Mishra, and B. Yin,
0020 % "Heterogeneous tensor decomposition for clustering via manifold
0021 % optimization", arXiv:1504.01777, 2015.
0022 %
0023 % Link to the paper: http://arxiv.org/abs/1504.01777.
0024 %
0025 % Please cite the Manopt paper as well as the research paper:
0026 % @Article{sun2015multinomial,
0027 %   author  = {Y. Sun and J. Gao and X. Hong and B. Mishra and B. Yin},
0028 %   title   = {Heterogeneous Tensor Decomposition for Clustering via Manifold Optimization},
0029 %   journal = {IEEE Transactions on Pattern Analysis and Machine Intelligence},
0030 %   year    = {2016},
0031 %   volume  = {38},
0032 %   number  = {3},
0033 %   pages   = {476--489},
0034 %   doi     = {10.1109/TPAMI.2015.2465901}
0035 % }
0036
0037 % This file is part of Manopt: www.manopt.org.
0038 % Original author: Bamdev Mishra, April 06, 2015.
0039 % Contributors:
0040 % Change log:
0041
0042     if ~exist('m', 'var') || isempty(m)
0043         m = 1;
0044     end
0045
0046     M.name = @() sprintf('%dx%d column-stochastic matrices with positive entries', n, m);
0047
0048     M.dim = @() (n-1)*m;
0049
0050     % We impose the Fisher metric.
0051     M.inner = @iproduct;
0052     function ip = iproduct(X, eta, zeta)
0053         ip = sum((eta(:).*zeta(:))./X(:));
0054     end
0055
0056     M.norm = @(X, eta) sqrt(M.inner(X, eta, eta));
0057
0058     M.dist = @(X, Y) error('multinomialfactory.dist not implemented yet.');
0059
0060     M.typicaldist = @() m*pi/2; % This is an approximation.
0061
0062     % Column vector of ones of length n.
0063     e = ones(n, 1);
0064
0065     M.egrad2rgrad = @egrad2rgrad;
0066     function rgrad = egrad2rgrad(X, egrad)
0067         lambda = -sum(X.*egrad, 1); % Row vector of length m.
0068         rgrad = X.*egrad + (e*lambda).*X; % This is in the tangent space.
0069     end
0070
0071     M.ehess2rhess = @ehess2rhess;
0072     function rhess = ehess2rhess(X, egrad, ehess, eta)
0073
0074         % Riemannian gradient computation.
0075         % lambda is a row vector of length m.
0076         lambda = - sum(X.*egrad, 1);
0077         rgrad =  X.*egrad + (e*lambda).*X;
0078
0079         % Directional derivative of the Riemannian gradient.
0080         % lambdadot is a row vector of length m.
0081         lambdadot = -sum(eta.*egrad, 1) - sum(X.*ehess, 1);
0082         rgraddot = eta.*egrad + X.*ehess + (e*lambdadot).*X + (e*lambda).*eta;
0083
0084         % Correction term because of the non-constant metric that we
0085         % impose. The computation of the correction term follows the use of
0086         % Koszul formula.
0087         correction_term = - 0.5*(eta.*rgrad)./X;
0088         rhess = rgraddot + correction_term;
0089
0090         % Finally, projection onto the tangent space.
0091         rhess = M.proj(X, rhess);
0092     end
0093
0094     % Projection of the vector eta in the ambeint space onto the tangent
0095     % space.
0096     M.proj = @projection;
0097     function etaproj = projection(X, eta)
0098         alpha = sum(eta, 1); % Row vector of length m.
0099         etaproj = eta - (e*alpha).*X;
0100     end
0101
0102     M.tangent = M.proj;
0103     M.tangent2ambient = @(X, eta) eta;
0104
0105     M.retr = @retraction;
0106     function Y = retraction(X, eta, t)
0107         if nargin < 3
0108             t = 1.0;
0109         end
0110         % A first-order retraction.
0111         Y = X.*exp(t*(eta./X)); % Based on mapping for positive scalars.
0112         Y = Y./(e*(sum(Y, 1))); % Projection onto the constraint set.
0113         % For numerical reasons, so that we avoid entries going to zero:
0114         Y = max(Y, eps);
0115     end
0116
0117     M.exp = @exponential;
0118     function Y = exponential(X, eta, t)
0119         if nargin < 3
0120             t = 1.0;
0121         end
0122         Y = retraction(X, eta, t);
0123         warning('manopt:multinomialfactory:exp', ...
0124             ['Exponential for the Multinomial manifold' ...
0125             'manifold not implemented yet. Used retraction instead.']);
0126     end
0127
0128     M.hash = @(X) ['z' hashmd5(X(:))];
0129
0130     M.rand = @random;
0131     function X = random()
0132         % A random point in the ambient space.
0133         X = rand(n, m); %
0134         X = X./(e*(sum(X, 1)));
0135     end
0136
0137     M.randvec = @randomvec;
0138     function eta = randomvec(X)
0139         % A random vector in the tangent space
0140         eta = randn(n, m);
0141         eta = M.proj(X, eta); % Projection onto the tangent space.
0142         nrm = M.norm(X, eta);
0143         eta = eta / nrm;
0144     end
0145
0146     M.lincomb = @matrixlincomb;
0147
0148     M.zerovec = @(X) zeros(n, m);
0149
0150     M.transp = @(X1, X2, d) projection(X2, d);
0151
0152     % vec and mat are not isometries, because of the scaled metric.
0153     M.vec = @(X, U) U(:);
0154     M.mat = @(X, u) reshape(u, n, m);
0155     M.vecmatareisometries = @() false;
0156 end```

Generated on Fri 08-Sep-2017 12:43:19 by m2html © 2005