Once a symmetric positive definite matrix is factored as ( lower triangular, np.linalg.cholesky is allowed), most Gaussian computations reduce to triangular operations. Implement five functions.
forward_sub(L, b): solve for lower-triangular L (shape (n, n), non-zero diagonal) and a 1-D b, by forward substitution: solve for first, then substitute it into the next equation, and so on.
back_sub(U, y): solve for upper-triangular U by back substitution (last unknown first).
Do not call np.linalg.solve, np.linalg.inv or scipy in these two functions.
chol_solve(A, b): solve for SPD A using the Cholesky factor and your two substitution routines.
logdet_chol(A): return as a float. It must stay finite when itself overflows or underflows double precision.
mvn_sample(mu, Sigma, eps): turn standard-normal draws into samples from . eps has shape (m, d) with one draw per row; return an (m, d) array whose row is with .