private void updateCholesky ( ) { // TODO: further improve handling of degenerated cases? CholeskyDecomposition chol = new CholeskyDecomposition ( covariance ) ; if ( ! chol . isSPD ( ) ) { // Add a small value to the diagonal, to reduce some rounding problems. double s = 0. ; for ( int i = 0 ; i < covariance . length ; i ++ ) { s += covariance [ i ] [ i ] ; } s *= SINGULARITY_CHEAT / covariance . length ; for ( int i = 0 ; i < covariance . length ; i ++ ) { covariance [ i ] [ i ] += s ; } chol = new CholeskyDecomposition ( covariance ) ; } if ( ! chol . isSPD ( ) ) { LOG . warning ( "A cluster has degenerated, likely due to lack of variance in a subset of the data or too extreme magnitude differences.\n" + // "The algorithm will likely stop without converging, and fail to produce a good fit." ) ; chol = this . chol != null ? this . chol : chol ; // Prefer previous } this . chol = chol ; logNormDet = FastMath . log ( weight ) - .5 * logNorm - getHalfLogDeterminant ( this . chol ) ; }
Update the cholesky decomposition .