本文整理汇总了Java中org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest类的典型用法代码示例。如果您正苦于以下问题:Java KolmogorovSmirnovTest类的具体用法?Java KolmogorovSmirnovTest怎么用?Java KolmogorovSmirnovTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KolmogorovSmirnovTest类属于org.apache.commons.math3.stat.inference包,在下文中一共展示了KolmogorovSmirnovTest类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDifference
import org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest; //导入依赖的package包/类
/**
* Test if two clusters are significantly different in the metrics we look at for balancing.
*
* @param orig the utilization matrix from the original cluster
* @param optimized the utilization matrix from the optimized cluster
* @return The P value that the various derived resources come from the same probability distribution. The probability
* that the null hypothesis is correct.
*/
public static double[] testDifference(double[][] orig, double[][] optimized) {
int nResources = RawAndDerivedResource.values().length;
if (orig.length != nResources) {
throw new IllegalArgumentException("orig must have number of rows equal to RawAndDerivedResource.");
}
if (optimized.length != nResources) {
throw new IllegalArgumentException("optimized must have number of rows equal to RawAndDerivedResource.");
}
if (orig[0].length != optimized[0].length) {
throw new IllegalArgumentException("The number of brokers must be the same.");
}
double[] pValues = new double[orig.length];
//TODO: For small N we want to do statistical bootstrapping (not the same as bootstrapping data).
for (int resourceIndex = 0; resourceIndex < nResources; resourceIndex++) {
RandomGenerator rng = new MersenneTwister(0x5d11121018463324L);
KolmogorovSmirnovTest kolmogorovSmirnovTest = new KolmogorovSmirnovTest(rng);
pValues[resourceIndex] =
kolmogorovSmirnovTest.kolmogorovSmirnovTest(orig[resourceIndex], optimized[resourceIndex]);
}
return pValues;
}
示例2: getImportances
import org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest; //导入依赖的package包/类
@Override
public double[] getImportances() {
KolmogorovSmirnovTest ks = new KolmogorovSmirnovTest();
double[] res = new double[nfeat];
for(int i = 0; i < nfeat; i++){
if(returnPval){
res[i] = ks.kolmogorovSmirnovTest(perfs, permPerfs[i]);
}
else{
res[i] = ks.kolmogorovSmirnovStatistic(perfs, permPerfs[i]);
}
}
return res;
}
示例3: equalityPValue
import org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest; //导入依赖的package包/类
public double equalityPValue() {
KolmogorovSmirnovTest uniformityTest = new KolmogorovSmirnovTest();
double uniformityPValue = uniformityTest.kolmogorovSmirnovTest(new UniformRealDistribution(), pValues.stream().mapToDouble(Double::doubleValue).toArray());
return uniformityPValue;
}
示例4: predictLabelsForColumn
import org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest; //导入依赖的package包/类
public boolean predictLabelsForColumn(Map<String, ArrayList<Double>> trainingLabelToExamplesMap,
ArrayList<Double> testExamples, int numPred, ArrayList<String> predictions, ArrayList<Double> confidenceScores) {
List<Prediction> sortedPredictions = new ArrayList<Prediction>(); // descending order of p-Value
KolmogorovSmirnovTest test = new KolmogorovSmirnovTest();
double pValue;
double[] sample1 = new double[testExamples.size()];
for(int i = 0; i < testExamples.size(); i++){
sample1[i] = testExamples.get(i);
}
for (Entry<String, ArrayList<Double>> entry : trainingLabelToExamplesMap.entrySet()) {
String label = entry.getKey();
ArrayList<Double> trainExamples = entry.getValue();
double[] sample2 = new double[trainExamples.size()];
for(int i = 0; i < trainExamples.size(); i++){
sample2[i] = trainExamples.get(i);
}
pValue = test.kolmogorovSmirnovTest(sample1, sample2);
Prediction pred = new Prediction(label, pValue);
sortedPredictions.add(pred);
}
// sorting based on p-Value
Collections.sort(sortedPredictions, new PredictionComparator());
for(int j=0; j<numPred && j<sortedPredictions.size(); j++)
{
predictions.add(sortedPredictions.get(j).predictionLabel);
confidenceScores.add(sortedPredictions.get(j).confidenceScore);
}
return true;
}