private static double computeKLD(double[] px,double[] py){
  double result=0;
  for (int i=0; i < px.length; i++) {
    double xi=Math.max(px[i],0.0000000001);
    double yi=Math.max(py[i],0.0000000001);
    result+=xi * Math.log(xi / yi);
  }
  return result;
}

private static double computeKLD ( double [ ] px , double [ ] py ) { double result = 0 ; for ( int i = 0 ; i < px . length ; i ++ ) { double xi = Math . max ( px [ i ] , 0.0000000001 ) ; double yi = Math . max ( py [ i ] , 0.0000000001 ) ; result += xi * Math . log ( xi / yi ) ; } return result ; }
compute the kullback - leibler divergence
