Class KullbackLeibler


  • public final class KullbackLeibler
    extends Object
    Calculate the Kullback–Leibler divergence between 2 distributions with the same variables, D(P||Q). A value of 0 indicates that the two distributions behave in a very similar or identical way.
    • Method Detail

      • divergence

        public static double divergence​(Distribution priorQ,
                                        Distribution posteriorP,
                                        LogarithmBase logarithm)
        Calculates the Kullback-Leibler divergence D(P||Q). Supports multivariate distributions. Supports discrete or continuous distributions.
        Parameters:
        priorQ - The distribution Q in D(P||Q), e.g. the Prior.
        posteriorP - The distribution P in D(P||Q), e.g. the Posterior.
        logarithm - The base of the computation.
        Returns:
        The Kullback-Leibler divergence in NATS if the logarithm is natural, BITS if the logarithm is base 2.