var#

var(x, rep_x, center=None)[source]#

Estimate the symmetry-constrained variance of \(\mathbf{X}:\Omega\to\mathcal{X}\).

Let \(\mathbf{X}: \Omega \to \mathcal{X}\) be a random variable taking values in the symmetric vector space \(\mathcal{X}\), with group representation \(\rho_{\mathcal{X}}:\mathbb{G}\to\mathrm{GL}(\mathcal{X})\), and marginal density \(\mathbb{P}_{\mathbf{X}}\). Under the assumption that this marginal is invariant under the group action (i.e., a point and all its symmetric points have equal likelihood under the marginal), formally:

\[\mathbb{P}_{\mathbf{X}}(\mathbf{x}) = \mathbb{P}_{\mathbf{X}}\!\left(\rho_{\mathcal{X}}(g)\mathbf{x}\right), \quad \forall \mathbf{x}\in\mathcal{X},\ \forall g\in\mathbb{G},\]

the true variance in the irrep-spectral basis (isotypic_decomp_rep()) is constant within each irreducible copy:

\[\operatorname{Var}(\hat{\mathbf{X}}_{k,i,1}) = \cdots = \operatorname{Var}(\hat{\mathbf{X}}_{k,i,d_k}) = \sigma^2_{k,i}.\]

Implementation: given samples \(\{\mathbf{x}^{(n)}\}_{n=1}^{N}\), we compute:

  1. Centering (using provided center or mean()):

\[\begin{split}\widehat{\boldsymbol{\mu}} = \begin{cases} \texttt{center}, & \text{if provided} \\ \widehat{\mathbb{E}}_{\mathbb{G}}[\mathbf{X}], & \text{otherwise} \end{cases}\end{split}\]
  1. Empirical spectral variance:

\[\hat{\mathbf{x}}^{(n)} = \mathbf{Q}^{T}(\mathbf{x}^{(n)}-\widehat{\boldsymbol{\mu}}),\qquad \widehat{v}_{j} = \frac{1}{N-1}\sum_{n=1}^{N}\left(\hat{x}^{(n)}_{j}\right)^2.\]
  1. Irrep-wise averaging for each copy \((k,i)\):

\[\widehat{\sigma}^{2}_{k,i} = \frac{1}{d_k}\sum_{r=1}^{d_k}\widehat{v}_{k,i,r}, \qquad \widehat{v}_{k,i,1}=\cdots=\widehat{v}_{k,i,d_k}:=\widehat{\sigma}^{2}_{k,i}.\]
  1. Mapping back to the original basis:

\[\widehat{\operatorname{Var}}(\mathbf{X}) = \mathbf{Q}^{\odot 2}\,\widehat{\mathbf{v}},\]

where \(\mathbf{Q}^{\odot 2}\) is the elementwise square of \(\mathbf{Q}\) and \(\widehat{\mathbf{v}}\) denotes the broadcast spectral variance vector after step 3.

Parameters:
  • x (Tensor) – (Tensor) samples with shape \((N,D_x)\) or \((N,D_x,T)\); the optional time axis is folded into samples.

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

  • center (Tensor) – (Tensor, optional) Center for variance computation. If None, computes the mean.

Returns:

Variance vector in the original basis, consistent with

the irrep-wise constraint above.

Return type:

(Tensor)

Shape:
  • x: \((N,D_x)\) or \((N,D_x,T)\).

  • center: \((D_x,)\) if provided.

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

Note

For repeated calls with the same representation object rep_x, this function caches and reuses: Q_inv, Q_squared, irrep_dims, and irrep_indices in rep_x.attributes.