Here you can find the source of vectorKLDivergence(double v1[], double v2[])
public static double vectorKLDivergence(double v1[], double v2[])
//package com.java2s; //License from project: Open Source License public class Main { public static double vectorKLDivergence(double v1[], double v2[]) { if (v1.length != v2.length) return Double.MAX_VALUE; double kl = 0.0; for (int i = 0; i < v1.length; i++) { kl += v1[i] * Math.log(v1[i] / v2[i]); }//from w w w.j av a2 s.c om return kl; } }