Skip to content
DeepForgeby svx
All problems
HardProbabilitypr-317

Kernel Matrix Log-Determinant

Problem

Build the squared exponential kernel matrix over the given points with additive noise variance noise on the diagonal, then return the natural log of its determinant using the Cholesky factorization as 2 times the sum of the log of the diagonal entries. Return 0.0 when the matrix is not positive definite or the inputs are invalid; an empty point list gives 0.0.

Hint

The determinant of a positive definite matrix is the squared product of the Cholesky diagonal.

Test cases

case 1
in: [[0],1,1]
expected: 0.6931471805599454
case 2
in: [[0,1],1,1]
expected: 1.28981665369822
case 3
in: [[0,1,2],2,0.5]
expected: 0.3587309450766028
case 4
in: [[],1,1]
expected: 0
case 5
in: [[0,1],0,1]
expected: 0
Starter codePython
import math


def kernel_matrix_log_determinant(points, length_scale, noise):
    # Your code here
    pass

5 test cases · run your code against them in the editor