bartz.testing.Factor

class bartz.testing.Factor(rank, tau)[source]

Identity plus random factors, \(R = (1 - \tau) I + \tau U U^\top\).

The rows of \(U\) (shape (k, rank)) are i.i.d. uniform on the unit sphere. rank=1 gives equicorrelation \(\pm\tau\) with random signs. Unlike LKJ, the spread of the correlations does not shrink with k.

rank: int

Number of factors, >= 1.

tau: Float[Array, ''] | float

Weight \(\tau\) of the factors, in [0, 1).

sample_chol(key, k)[source]

Sample the factors and factorize their correlation matrix.

Return type:

Float[Array, 'k k']

offdiag_var(k)[source]

E[R_cc' ** 2] = tau ** 2 / rank.

Return type:

Float[Array, ''] | float