private double pdf ( double x , int j ) { /* * n * ===== /x - x \ * 1 \ | i| * f(x) = --- > K|------| * n h / \ h / * ===== * i = 1 * */ //Only values within a certain range will have an effect on the result, so we will skip to that range! int from = Arrays . binarySearch ( X , x - h * k . cutOff ( ) ) ; int to = Arrays . binarySearch ( X , x + h * k . cutOff ( ) ) ; //Mostly likely the exact value of x is not in the list, so it returns the inseration points from = from < 0 ? - from - 1 : from ; to = to < 0 ? - to - 1 : to ; //Univariate opt, if uniform weights, the sum is just the number of elements divide by half if ( weights . length == 0 && k instanceof UniformKF ) return ( to - from ) * 0.5 / ( sumOFWeights * h ) ; double sum = 0 ; for ( int i = Math . max ( 0 , from ) ; i < Math . min ( X . length , to + 1 ) ; i ++ ) if ( i != j ) sum += k . k ( ( x - X [ i ] ) / h ) * getWeight ( i ) ; return sum / ( sumOFWeights * h ) ; }
Computes the Leave One Out PDF of the estimator