All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.TKnudsen.ComplexDataObject.model.statistics.JensenShannonDivergence Maven / Gradle / Ivy

Go to download

A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.

The newest version!
package com.github.TKnudsen.ComplexDataObject.model.statistics;

import com.github.TKnudsen.ComplexDataObject.model.distanceMeasure.Double.probabilities.KullbackLeiblerDivergenceDistance;

/**
 * 

* Title: JensenShannonDivergence *

* *

* Description: calculates the Jensen Shannon Divergence - a measure to assess * the difference between to probability distibutions. *

* *

* Copyright: Copyright (c) 2018 *

* * @author Juergen Bernard * @version 1.01 */ public class JensenShannonDivergence { /** * * @param a * @param b * @return */ public static double jensenShannonDivergence(double[] a, double[] b) { double[] med = new double[a.length]; for (int i = 0; i < med.length; i++) med[i] = (a[i] + b[i]) / 2; KullbackLeiblerDivergenceDistance kld = new KullbackLeiblerDivergenceDistance(true); return (kld.dist(a, med) + kld.dist(b, med)) * 0.5; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy