Fork me on GitHub

src/arraymancer/linear_algebra/decomposition_rand

Search:
Group by:
  Source Edit

Procs

proc svd_randomized[T](A: Tensor[T]; n_components = 2; n_oversamples = 5;
                       n_power_iters = 2): tuple[U, S, Vh: Tensor[T]]

Compute approximate nearly optimal truncated Singular Value Decomposition of an input matrix a.

Decomposition is truncated to nb_components.

Increasing nb_oversamples or nb_iter increases the accuracy of the approximation

Input:

  • A, a matrix of shape M, N
  • nb_components: rank/dimension of the approximation i.e. number of singular values and vectors to extract Must be lower than min(M, N) Default to 2 for 2D visualization
  • nb_oversamples: Additional number of random projections in the sampling matrix Recommended range 2 .. 10
  • nb_power_iter: Number of power iterations Power iterations enforce rapid decay of singular values and allow the algorithm to sample dominant singular values and suppress irrelevant information. Useful for noisy problems.

Returns: with K = nb_components

  • U: Unitary matrix of shape M, K with rank-K approximation of left singular vectors as columns
  • S: Rank-k approximation of singular values diagonal of length K in decreasing order
  • Vh: Unitary matrix of shape K, N with rank-K approximation of right singular vectors as rows

This is an approximate solution of the equation: A = U S V.h

  • with S being a diagonal matrix of singular values
  • with V being the right singular vectors and V.h being the hermitian conjugate of V for real matrices, this is equivalent to V.t (transpose)

⚠️: Input must not contain NaN

Exception:

  • This can throw if the algorithm did not converge.

References:

  Source Edit
Arraymancer Technical reference Tutorial Spellbook (How-To's) Under the hood