sparsax.sample_gaussian

sparsax.sample_gaussian(Ai, Aj, Ax, b, z, want_logdet=False)[source]

Draw eta ~ N(A^{-1} b, A^{-1}) from a single factorization of A.

The Gibbs Gaussian-conditional step in one factorization: the posterior mean A^{-1} b and the correlated draw share one Cholesky factor. With A = P' L L' P, a sample is eta = mean + P' L^{-T} z for z ~ N(0, I), since Cov(P' L^{-T} z) = A^{-1}. Built on factor_solve(), so under vmap it factors once per element.

Parameters:
Ai

COO of the SPD precision matrix A.

Aj

COO of the SPD precision matrix A.

Ax

COO of the SPD precision matrix A.

b

[n] or [n, n_rhs] — mean numerator (posterior mean is A^{-1} b).

z

standard-normal draw with the same shape as b.

want_logdet=False

if True, also return log|A|.

Returns:

(eta, mean), or (eta, mean, logdet) if want_logdet.