private double loglikelihoodNormal ( DBIDs objids , SetDBIDs anomalous , CovarianceMatrix builder , Relation < V > relation ) { double [ ] mean = builder . getMeanVector ( ) ; final LUDecomposition lu = new LUDecomposition ( builder . makeSampleMatrix ( ) ) ; double [ ] [ ] covInv = lu . inverse ( ) ; // for each object compute probability and sum double prob = ( objids . size ( ) - anomalous . size ( ) ) * - FastMath . log ( FastMath . sqrt ( MathUtil . powi ( MathUtil . TWOPI , RelationUtil . dimensionality ( relation ) ) * lu . det ( ) ) ) ; for ( DBIDIter iter = objids . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { if ( ! anomalous . contains ( iter ) ) { double [ ] xcent = minusEquals ( relation . get ( iter ) . toArray ( ) , mean ) ; prob -= .5 * transposeTimesTimes ( xcent , covInv , xcent ) ; } } return prob ; }
Computes the loglikelihood of all normal objects . Gaussian model