Cholesky Decomposition
Cholesky decomposition (or Cholesky factorization) is a method used to decompose a symmetric, positive-definite matrix into the product of a lower triangular matrix and its transpose.
- is symmetric and positive-definite
- is lower triangular
I used this to sample gaussian numbers given a Covariance Matrix.
from sklearn.gaussian_process.kernels import RBF
from scipy.linalg import cholesky
T = 100
dim = 2
length_scale = 10.0 # Controls smoothness
sigma = 0.1 # Noise level
# Define temporal covariance matrix
time_points = np.arange(T).reshape(-1, 1)
kernel = RBF(length_scale=length_scale)
K = kernel(time_points) * sigma**2
# Sample correlated noise for each dimension
L = cholesky(K + 1e-6 * np.eye(T))
epsilon = np.dot(L, np.random.randn(T, dim))
noisy_trajectory = trajectory + epsilon
Why do we need to do the cholesky decomposition to get ? Why can’t we just use ?
Because the covariance