Problem
I am practicing writing efficient Julia code that could (hopefully) comparable with the function provided in libraries in term of speed. Specifically, I am trying to write logpdf
function, which returns the log probability of given input.
However, when I evaluate the determinant of random vector’s covariance, i.e. \Sigma=\sigma_0^2 \mathbf{I} + \sigma_1^2 \mathbf{ZZ}^T where \mathbf{Z} \in \mathbb{R}^{n\times q}. The determinant is 0.
I think this is due to the matrix is not well-conditioned, but I am not sure how to resolve this issue.
using Random, LinearAlgebra
Random.seed!(280)
n, q = 1000, 10
Z = randn(n, q)
σ0, σ1 = 0.5, 2.0
Σ = σ1^2 * Z * Z' + σ0^2 * I
det(Σ)
Could anyone help me, thank you in advance.