Last chance! 50% off unlimited learning
Sale ends in
mat.rank(mat, tol)
tol
are considered non-zero.mat.rank
estimate the rank of a matrix by
computing its singular values $d[i]$ (using nipals
).
The rank of the matrix can be defined as
the number of singular values $d[i] > 0$.
If tol
is missing, it is given by
tol=max(dim(mat))*max(d)*.Machine$double.eps
.nipals
## Hilbert matrix
hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") }
mat <- hilbert(16)
mat.rank(mat)
## Hilbert matrix with missing data
idx.na <- matrix(sample(c(0, 1, 1, 1, 1), 36, replace = TRUE), ncol = 6)
m.na <- m <- hilbert(9)[, 1:6]
m.na[idx.na == 0] <- NA
mat.rank(m)
mat.rank(m.na)
Run the code above in your browser using DataLab