本文整理汇总了Java中org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic类的典型用法代码示例。如果您正苦于以下问题:Java StorelessUnivariateStatistic类的具体用法?Java StorelessUnivariateStatistic怎么用?Java StorelessUnivariateStatistic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StorelessUnivariateStatistic类属于org.apache.commons.math3.stat.descriptive包,在下文中一共展示了StorelessUnivariateStatistic类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCopyConsistencyWithInitialMostElements
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
/**
* Verifies that copied statistics remain equal to originals when
* incremented the same way by making the copy after a majority of elements
* are incremented
*/
@Test
public void testCopyConsistencyWithInitialMostElements() {
StorelessUnivariateStatistic master =
(StorelessUnivariateStatistic) getUnivariateStatistic();
StorelessUnivariateStatistic replica = null;
// select a portion of testArray till 75 % of the length to load first
long index = FastMath.round(0.75 * testArray.length);
// Put first half in master and copy master to replica
master.incrementAll(testArray, 0, (int) index);
replica = master.copy();
// Check same
Assert.assertTrue(replica.equals(master));
Assert.assertTrue(master.equals(replica));
// Now add second part to both and check again
master.incrementAll(testArray, (int) index,
(int) (testArray.length - index));
replica.incrementAll(testArray, (int) index,
(int) (testArray.length - index));
Assert.assertTrue(replica.equals(master));
Assert.assertTrue(master.equals(replica));
}
示例2: testCopyConsistencyWithInitialFirstFewElements
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
/**
* Verifies that copied statistics remain equal to originals when
* incremented the same way by way of copying original after just a few
* elements are incremented
*/
@Test
public void testCopyConsistencyWithInitialFirstFewElements() {
StorelessUnivariateStatistic master =
(StorelessUnivariateStatistic) getUnivariateStatistic();
StorelessUnivariateStatistic replica = null;
// select a portion of testArray which is 10% of the length to load
// first
long index = FastMath.round(0.1 * testArray.length);
// Put first half in master and copy master to replica
master.incrementAll(testArray, 0, (int) index);
replica = master.copy();
// Check same
Assert.assertTrue(replica.equals(master));
Assert.assertTrue(master.equals(replica));
// Now add second part to both and check again
master.incrementAll(testArray, (int) index,
(int) (testArray.length - index));
replica.incrementAll(testArray, (int) index,
(int) (testArray.length - index));
Assert.assertTrue(master.equals(master));
Assert.assertTrue(replica.equals(replica));
Assert.assertTrue(replica.equals(master));
Assert.assertTrue(master.equals(replica));
}
示例3: evaluate
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
@Override
public FieldValue evaluate(List<FieldValue> arguments){
StorelessUnivariateStatistic statistic = createStatistic();
DataType dataType = null;
// "Missing values in the input to an aggregate function are simply ignored"
Iterable<FieldValue> values = Iterables.filter(arguments, Predicates.notNull());
for(FieldValue value : values){
statistic.increment((value.asNumber()).doubleValue());
if(dataType != null){
dataType = TypeUtil.getResultDataType(dataType, value.getDataType());
} else
{
dataType = value.getDataType();
}
}
// "If all inputs are missing, then the result evaluates to a missing value"
if(statistic.getN() == 0){
return null;
}
Double result = statistic.getResult();
return FieldValueUtil.create(getResultType(dataType), OpType.CONTINUOUS, result);
}
示例4: rootMeanSquaredError
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
/**
* @param classifier a {@link com.cloudera.oryx.rdf.common.tree.TreeBasedClassifier} (e.g. {@link com.cloudera.oryx.rdf.common.tree.DecisionForest})
* trained on data with a numeric target
* @param testSet test set to evaluate on
* @return root mean squared error over the test set square root of mean squared difference between actual
* and predicted numeric target value
*/
public static double rootMeanSquaredError(TreeBasedClassifier classifier, Iterable<Example> testSet) {
StorelessUnivariateStatistic mse = new Mean();
for (Example test : testSet) {
NumericFeature actual = (NumericFeature) test.getTarget();
NumericPrediction prediction = (NumericPrediction) classifier.classify(test);
double diff = actual.getValue() - prediction.getPrediction();
mse.increment(diff * diff);
}
return FastMath.sqrt(mse.getResult());
}
示例5: meanAbs
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
/**
* @param testSet test set to evaluate on
* @return average absolute value of numeric target value in the test set
*/
private static double meanAbs(Iterable<Example> testSet) {
StorelessUnivariateStatistic mean = new Mean();
for (Example test : testSet) {
NumericFeature actual = (NumericFeature) test.getTarget();
mean.increment(FastMath.abs(actual.getValue()));
}
return mean.getResult();
}
示例6: buildNumericPrediction
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
static NumericPrediction buildNumericPrediction(Iterable<Example> examples) {
StorelessUnivariateStatistic mean = new Mean();
for (Example example : examples) {
mean.increment(((NumericFeature) example.getTarget()).getValue());
}
Preconditions.checkState(mean.getN() > 0);
return new NumericPrediction((float) mean.getResult(), (int) mean.getN());
}
示例7: copy
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
@Override
public StorelessUnivariateStatistic copy() {
return new NullStorelessUnivariateStatistic();
}
示例8: JsonStorelessStatistic
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
public JsonStorelessStatistic(Statistic stat, StorelessUnivariateStatistic statImpl) {
this.stat = stat;
this.statImpl = statImpl;
}
示例9: checkClearValue
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
@Override
protected void checkClearValue(StorelessUnivariateStatistic statistic){
Assert.assertEquals(0, statistic.getResult(), 0);
}
示例10: checkClearValue
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
@Override
protected void checkClearValue(StorelessUnivariateStatistic statistic){
Assert.assertEquals(1, statistic.getResult(), 0);
}
示例11: AbstractStorelessStatistic
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
protected AbstractStorelessStatistic(final StorelessUnivariateStatistic stat) {
this.stat = stat;
}
示例12: AbstractCumulativeFunction
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
protected AbstractCumulativeFunction(final StorelessUnivariateStatistic stat, final Number initialValue) {
this.stat = stat;
this.initialValue = initialValue;
reset();
}
示例13: createStatistic
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
abstract
public StorelessUnivariateStatistic createStatistic();
示例14: setSumLogImpl
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入依赖的package包/类
/**
* <p>Sets the implementation for the sum of logs.</p>
* <p>This method must be activated before any data has been added - i.e.,
* before {@link #increment(double) increment} has been used to add data;
* otherwise an IllegalStateException will be thrown.</p>
*
* @param sumLogImpl the StorelessUnivariateStatistic instance to use
* for computing the log sum
* @throws MathIllegalStateException if data has already been added
* (i.e if n > 0)
*/
public void setSumLogImpl(StorelessUnivariateStatistic sumLogImpl)
throws MathIllegalStateException {
checkEmpty();
this.sumOfLogs = sumLogImpl;
}