nnmf
statistics: [W, H] = nnmf (A, K)
statistics: [W, H, D] = nnmf (A, K)
statistics: […] = nnmf (…, Name, Value)
Nonnegative matrix factorization.
[W, H] = nnmf (A, K) factors the nonnegative
matrix A into nonnegative factors W () and H () whose product approximates
A, by minimizing the root-mean-square residual between A and
W * H. K, the number of factors, is typically smaller
than and .
[W, H, D] = nnmf (…) also returns the
root-mean-square residual D, that is norm (A - W *
H, "fro") / sqrt (N * M).
The factorization is not unique: the returned factors are normalized so that
the rows of H have unit length, and the columns of W (and the
corresponding rows of H) are ordered by decreasing length of the
columns of W. Because the objective is not convex, the iteration
converges to a local minimum that depends on the starting point; use
'Replicates' to try several random starts and keep the best.
Name/Value pairs:
'Algorithm''als' (default) for alternating least squares, or 'mult' for
multiplicative updates. Alternating least squares usually converges faster
and more reliably; multiplicative updates are more sensitive to the starting
point.'W0''H0''Replicates''W0' and 'H0'.'Options'statset) whose
MaxIter, TolFun, and TolX fields control the iteration.Source Code: nnmf
Factor a nonnegative matrix into two rank-2 nonnegative factors.
A = [1, 2, 3; 2, 4, 6; 3, 5, 7; 4, 8, 12]; [W, H, D] = nnmf (A, 2); D
D = 2.6952e-15
W * H approximates A.
W * H
ans =
1 2 3
2 4 6
3 5 7
4 8 12