gov.sandia.cognition.learning.function.cost.KolmogorovSmirnovDivergence Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cognitive-foundry Show documentation
Show all versions of cognitive-foundry Show documentation
A single jar with all the Cognitive Foundry components.
/*
* File: KolmogorovSmirnovDivergence.java
* Authors: Kevin R. Dixon
* Company: Sandia National Laboratories
* Project: Cognitive Foundry
*
* Copyright Jul 12, 2010, Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the U.S. Government.
* Export of this program may require a license from the United States
* Government. See CopyrightHistory.txt for complete details.
*
*/
package gov.sandia.cognition.learning.function.cost;
import gov.sandia.cognition.statistics.CumulativeDistributionFunction;
import gov.sandia.cognition.statistics.UnivariateDistribution;
import gov.sandia.cognition.statistics.method.KolmogorovSmirnovConfidence;
import java.util.Collection;
/**
* CostFunction that induces a CDF that most-closely resembles the
* target distribution according to the Kolmogorov-Smirnov (K-S) test.
* @param
* Type of data generated by the Distribution
*/
public class KolmogorovSmirnovDivergence
extends AbstractCostFunction,Collection extends DataType>>
{
/**
* Default constructor
*/
public KolmogorovSmirnovDivergence()
{
this( null );
}
/**
* Creates a new instance of KolmogorovSmirnovDivergence
* @param costParameters
* Data generated by the target distribution
*/
public KolmogorovSmirnovDivergence(
Collection extends DataType> costParameters)
{
super( costParameters );
}
@Override
public Double evaluate(
UnivariateDistribution target)
{
CumulativeDistributionFunction cdf = target.getCDF();
KolmogorovSmirnovConfidence.Statistic kstest =
KolmogorovSmirnovConfidence.evaluateNullHypothesis(
this.getCostParameters(),cdf);
double d = kstest.getD();
return d;
}
}