cov#

cov(x, y, rep_x, rep_y, uncentered=False)[source]#

Compute symmetry-aware cross-covariance.

Let \(\mathbf{X}:\Omega\to\mathcal{X}\) and \(\mathbf{Y}:\Omega\to\mathcal{Y}\) be two \(\mathbb{G}\)-invariant random variables endowed with the \(\mathbb{G}\) representations \(\rho_{\mathcal{X}}\) and \(\rho_{\mathcal{Y}}\) respectively. This function computes the symmetry-aware cross-covariance which by construction is a \(\mathbb{G}\)-equivariant linear map in \(\mathrm{Hom}_{\mathbb{G}}(\rho_{\mathcal{X}},\rho_{\mathcal{Y}})\).

Implementation: To achieve this we first compute the symmetry-agnostic empirical covariance \(\mathbf{C}^{\text{raw}}_{yx} = \frac{1}{N-1}\sum_{n=1}^{N}\mathbf{y}^{\star}_n (\mathbf{x}^{\star}_n)^\top\). By default (uncentered=False), centered variables use invariant means from mean(): \(\mathbf{x}^{\star}_n = \mathbf{x}_n - \boldsymbol{\mu}_x\), \(\mathbf{y}^{\star}_n = \mathbf{y}_n - \boldsymbol{\mu}_y\), with \(\boldsymbol{\mu}_x = \widehat{\mathbb{E}}_{\mathbb{G}}[\mathbf{X}]\), \(\boldsymbol{\mu}_y = \widehat{\mathbb{E}}_{\mathbb{G}}[\mathbf{Y}]\). If uncentered=True, \(\mathbf{x}^{\star}_n=\mathbf{x}_n\) and \(\mathbf{y}^{\star}_n=\mathbf{y}_n\).

The returned covariance is the orthogonal projection of \(\mathbf{C}^{\text{raw}}_{yx}\) onto \(\mathrm{Hom}_{\mathbb{G}}(\rho_{\mathcal{X}},\rho_{\mathcal{Y}})\) via equiv_orthogonal_projection():

\[\mathbf{C}_{yx} = \Pi_{\mathrm{Hom}_{\mathbb{G}}}(\mathbf{C}^{\text{raw}}_{yx}).\]

This orthogonal projector is equivalent to the Reynolds/group-average operator:

\[\Pi_{\mathrm{Hom}_{\mathbb{G}}}(\mathbf{A}) = \frac{1}{|\mathbb{G}|}\sum_{g\in\mathbb{G}} \rho_{\mathcal{Y}}(g)\,\mathbf{A}\,\rho_{\mathcal{X}}(g^{-1}).\]
Parameters:
  • x (Tensor) – Samples of \(\mathbf{X}\).

  • y (Tensor) – Samples of \(\mathbf{Y}\).

  • rep_x (Representation) – Representation \(\rho_{\mathcal{X}}\).

  • rep_y (Representation) – Representation \(\rho_{\mathcal{Y}}\).

  • uncentered (bool) – If False (default), subtract invariant means before covariance computation. If True, compute the uncentered second moment and project it.

Returns:

Projected cross-covariance \(\mathbf{C}_{yx}\) with shape \((D_y, D_x)\).

Return type:

Tensor

Shape:
  • x: \((N, D_x)\). With N denoting the number of samples and D_x the dimension of the

    representation space of x.

  • y: \((N, D_y)\). With D_y the dimension of the representation space of y.

  • Output: \((D_y, D_x)\).