gemmr.generative_model._variance_explained_by_latent_modes

gemmr.generative_model._variance_explained_by_latent_modes(Sigmaxx, Sigmayy, U_, V_, expl_var_ratio_thr)

Calculates the amount of explained variance by the between-set associations and checks if they surpass a threshold.

The fraction of explained variance along a direction specified by a given weight vector is calculated as

\[\frac{\vec{w}^T \Sigma \vec{w}}{\mathrm{tr}(\Sigma)}\]

To decide whether the given weight vectors explain “enough” variance, the explained variance (separately for X and Y) of the first mode is compared to the mean variance of a mode and if the ratio of the 2 is above expl_var_ratio_thr we interpret this as “enough”.

Parameters:
  • Sigmaxx (np.ndarray (px, px)) – within-set covariance for X
  • Sigmayy (np.ndarray (py, py)) – within-set covariance for Y
  • U (np.ndarray (px, m)) – weight vectors for X
  • V (np.ndarray (py, m)) – weight vectors for Y
  • expl_var_ratio_thr (float) – the ratio of the amount of variance along the first mode vectors in X and Y to the mean variance along a mode in X and Y needs to surpass this number.
Returns:

  • enough_variance_explained (bool) – True, if “enough” variance is explained for both X and Y, False otherwise
  • latent_expl_var_ratios_x (np.ndarray (m,)) – explained variance ratios for each mode in X
  • latent_expl_var_ratios_y (np.ndarray (m,)) – explained variance ratios for each mode in Y