I'd like to compute a low-rank approximation to a matrix which is optimal under the Frobenius norm. The trivial way to do this is to compute the SVD decomposition of the matrix, set the smallest singular values to zero and compute the low-rank matrix by multiplying the factors. Is there a simple and more efficient way to do this in MATLAB?
相关问题
- Extract matrix elements using a vector of column i
- How to perform element-wise custom function with t
- How do you get R's null and residual deviance
- How to display an image represented by three matri
- OpenCV - Is there an implementation of marker base
相关文章
- Which is the best way to multiply a large and spar
- How do I append metadata to an image in Matlab?
- How can I write-protect the Matlab language?
- `std::sin` is wrong in the last bit
- Escape sequence to display apostrophe in MATLAB
- Vertical line fit using polyfit
- How to calculate end points of perpendicular line
- Reading .mat file using C: how to read cell-struct
If your matrix is sparse, use
svds
.Assuming it is not sparse but it's large, you can use random projections for fast low-rank approximation.
From a tutorial:
Matlab code from a blog:
Also, remember the
econ
parameter ofsvd
.You can rapidly compute a low-rank approximation based on SVD, using the
svds
function.svds
useseigs
to compute a subset of the singular values - it will be especially fast for large, sparse matrices. See the documentation; you can set tolerance and maximum number of iterations or choose to calculate small singular values instead of large.I thought
svds
andeigs
could be faster thansvd
andeig
for dense matrices, but then I did some benchmarking. They are only faster for large matrices when sufficiently few values are requested:With size-
n
square matrices,k
singular/eigen values and runtimes in seconds. I used Steve Eddins'timeit
file exchange function for benchmarking, which tries to account for overhead and runtime variations.svds
andeigs
are faster if you want a few values from a very large matrix. It also depends on the properties of the matrix in question (edit svds
should give you some idea why).