本文整理汇总了Java中org.apache.commons.math3.stat.inference.TTest.tTest方法的典型用法代码示例。如果您正苦于以下问题:Java TTest.tTest方法的具体用法?Java TTest.tTest怎么用?Java TTest.tTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.stat.inference.TTest
的用法示例。
在下文中一共展示了TTest.tTest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkTimeSeriesSimularityTtest
import org.apache.commons.math3.stat.inference.TTest; //导入方法依赖的package包/类
private boolean checkTimeSeriesSimularityTtest(double[] r_generated, double[] java_generated) {
TTest t_test_obj = new TTest();
// Performs a paired t-test evaluating the null hypothesis that the mean of the paired
// differences between sample1
// and sample2 is 0 in favor of the two-sided alternative that the mean paired difference is not
// equal to 0,
// with significance level 0.05.
double p_value = t_test_obj.tTest(r_generated, java_generated);
boolean reject_null_hyphothesis = (p_value < 0.05);
return reject_null_hyphothesis;
}
示例2: evaluate
import org.apache.commons.math3.stat.inference.TTest; //导入方法依赖的package包/类
@Override
public double evaluate(double[] baseline, double[] treatment) {
double[] boostedBaseline = multiply(baseline, boost);
/*
double sampleSum = 0;
double sampleSumSquares = 0;
int n = boostedBaseline.length;
for (int i = 0; i < baseline.length; i++) {
double delta = treatment[i] - boostedBaseline[i];
sampleSum += delta;
sampleSumSquares += delta * delta;
}
double sampleVariance = sampleSumSquares / (n - 1);
double sampleMean = sampleSum / baseline.length;
double sampleDeviation = Math.sqrt(sampleVariance);
double meanDeviation = sampleDeviation / Math.sqrt(n);
double t = sampleMean / meanDeviation;
return 1.0 - Stat.studentTProb(t, n - 1);
*/
//- Use Apache Commons Math3 directly for t-test p-value calculation
TTest tt = new TTest();
double pval = tt.tTest (boostedBaseline, treatment);
return 1.0 - pval;
}
示例3: checkTimeSeriesSimularityTtest
import org.apache.commons.math3.stat.inference.TTest; //导入方法依赖的package包/类
private boolean checkTimeSeriesSimularityTtest(double[] r_generated, double[] java_generated) {
TTest t_test_obj = new TTest();
// Performs a paired t-test evaluating the null hypothesis that the mean of the paired differences between sample1
// and sample2 is 0 in favor of the two-sided alternative that the mean paired difference is not equal to 0,
// with significance level 0.05.
double p_value = t_test_obj.tTest(r_generated, java_generated);
boolean reject_null_hyphothesis = (p_value < 0.05);
return reject_null_hyphothesis;
}
示例4: predictLabelsForColumn
import org.apache.commons.math3.stat.inference.TTest; //导入方法依赖的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
TTest test = new TTest();
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.tTest(sample1, sample2);
Prediction pred = new Prediction(label, pValue);
// double tValue = Math.abs(test.t(sample1, sample2));
// Prediction pred = new Prediction(label, tValue);
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;
}