Hands-on lab · 1 step
The RBF Gram matrix
Implement the Gram matrix of the Gaussian (RBF) kernel, the matrix that the SVM dual and every kernel method consume. The grader checks your values on a visible three-point example and on three hidden sets of random points in (), and verifies the two structural properties that every valid Gram matrix has: symmetry and positive semidefiniteness.
Step 1: Compute the RBF Gram matrix
Write the TypeScript function rbfGram with signature
where row of X is the data point and gamma is . Return a plain array of rows of numbers each. The norm is squared: no square root is taken.
Visible test three-points: and . The squared distances are , and , so
compared entrywise with absolute tolerance .
Hidden tests (arguments are sent to your browser, expected values are not): three data sets of points in with , and . For each set: (values) every entry within of the reference matrix; (symmetric) ; (psd) the smallest eigenvalue of , computed by the engine's Hermitian eigensolver, is at least .
Use Math.exp; do not import anything.