| fs_sym_root | R Documentation |
Computes the symmetric matrix square root of scale * S after
symmetrising S as (S + t(S)) / 2: with eigendecomposition
S = V D V', the returned matrix is R = V D^{1/2} V' (eigenvalues
scaled by scale and clamped at zero before the square root), so that
R R' = \mathrm{scale} \cdot S.
fs_sym_root(S, scale = 2)
S |
Numeric square matrix, a covariance (or any matrix whose
symmetrisation |
scale |
Numeric scalar multiplying |
A symmetric numeric matrix R of the same dimension as
S, satisfying R %*% t(R) equal to scale times the
symmetrised S (up to the zero-clamp on negative eigenvalues).
Both roots satisfy R R' = \mathrm{scale} \cdot S, but the asymmetric
root V D^{1/2} depends on the eigenvector basis, which is not a
continuous function of its input: signs flip and vectors rotate freely
inside degenerate subspaces – which a candidate covariance built from
complement pairs has exactly, since the complement constraints make it
rank-deficient by construction. A pinned RNG seed fixes the standard-normal
draws Z; it cannot fix the basis Z is multiplied by, so the asymmetric root
is non-reproducible across arithmetically equivalent routes to the same
matrix. The symmetric root V D^{1/2} V' is a matrix function of the
symmetrised input alone – basis-free and continuous – so samples built
from it are continuous, reproducible functions of the inputs.
S <- crossprod(matrix(rnorm(25), 5)) # symmetric positive definite
R <- fs_sym_root(S, scale = 2)
max(abs(R %*% t(R) - 2 * S)) # ~ 1e-14
isSymmetric(R)
# Rank-deficient input: the root exists and stays symmetric
X <- matrix(rnorm(15), 5, 3)
R2 <- fs_sym_root(tcrossprod(X), scale = 1)
max(abs(R2 %*% t(R2) - tcrossprod(X)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.