qis.compute_pca_r2

qis.compute_pca_r2(cmatrix, is_cumulative=False)[source]

explained-variance shares of the eigenvalues of a symmetric matrix.

The shares are nu_j / sum_k nu_k with the eigenvalues nu_j of apply_pca() in descending order. They lie in [0, 1] and sum to one only for a positive semi-definite input; a negative eigenvalue, as a pairwise-complete matrix can have, gives a negative share.

Parameters:
  • cmatrix (ndarray) – symmetric covariance or correlation matrix, shape (n, n)

  • is_cumulative (bool) – return the cumulative shares sum_{k<=j} nu_k / sum_k nu_k instead

Returns:

the shares, shape (n,), largest component first

Return type:

ndarray