Sminding eigenvalues with the characteristic polynomial

For a square matrix A, any eigenvector v and corresponding eigenvalue λ of A must satisfy the equaion Av = λv. Some rearranging yields (A - λI)v = 0. Which is true if v = 0 (trivial) or if the transformation A - λI is singular (capable of banishing something other than the zero vector to zero). If the transformation is singular, it has a determinant of 0, which is why the roots of |λI - A| = 0 are the eigenvalues of A.

Something Volume Parameters
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
affinity_matrix <- function(dist, K = 20, alpha = 0.5) {
N <- nrow(dist)
dist <- (dist + t(dist)) / 2
diag(dist) <- 0
sorted_dist <- as.matrix(t(apply(dist, 2, sort)))
k_nearest_cols <- sorted_dist[, 1:K+1]
finiteMean <- function(x) mean(x[is.finite(x)])
means <- apply(k_nearest_cols,1,finiteMean)
means <- means + .Machine$double.eps
avg <- function(x,y) (x + y) / 2
pairwise_avgs <- outer(means, means, avg)
sd <- (2/3 * pairwise_avgs) + dist/3 + .Machine$double.eps
sd[sd < .Machine$double.eps] <- .Machine$double.eps
densities <- dnorm(dist, 0, alpha * sd)
densities <- (densities + t(densities)) / 2
return(densities)
}

Before stepping through the code line-by-line,

  1. Any x <- (x + t(x)) / 2 is done to ensure x is perfectly symmetric.
  2. Any x <- x + .Machine$double.eps is done to avoid division by zero.

Lines 1 to 4

The function accepts a distance matrix containing the pairwise distances of n observations, D(n times n), a sparsification hyperparameter K, and a normalizing hyperparameter alpha. The diagonals of D, which represent the distances between observations and themselves, are then set to the minimum value of 0.

[1]

Bibliography

hi