本文整理汇总了Java中org.apache.commons.math.stat.descriptive.moment.StandardDeviation类的典型用法代码示例。如果您正苦于以下问题:Java StandardDeviation类的具体用法?Java StandardDeviation怎么用?Java StandardDeviation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StandardDeviation类属于org.apache.commons.math.stat.descriptive.moment包,在下文中一共展示了StandardDeviation类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BucketSampler
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
BucketSampler(int maxSize, long estimatedInputs, boolean calculateStandardDeviation) {
if (maxSize < 1)
throw new IllegalArgumentException("max must be at least 1");
if (estimatedInputs < 0)
throw new IllegalArgumentException("estimatedInputs must be non-negative: " + estimatedInputs);
this.maxSize = maxSize;
this.estimatedInputs = estimatedInputs;
this.buckets = new ArrayList<>(maxSize + 1);
this.stdDev = calculateStandardDeviation ? new StandardDeviation() : null;
computeMedianPointBoundaries(maxSize);
}
示例2: calculateStandardDeviation
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
/**
* Calculates the standard deviation of all attribute values.
*
* @param attributeValues attribute values
* @return the standard deviation
*/
public Double calculateStandardDeviation( Comparable[] attributeValues,
Double mean ) {
StandardDeviation standardDeviation = new StandardDeviation();
Double evaluatedStdDev = standardDeviation.evaluate(
convertToPrimitives( attributeValues ), mean );
log.debug( "standardDeviation( " + mean + " ) = " + evaluatedStdDev );
return evaluatedStdDev;
}
示例3: export
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
@Override
public void export(RandomAccessMDLReader reader, EncodingFingerprint fingerprinter, String label, File outputFile, boolean useAromaticFlag) {
DecimalFormat df = new DecimalFormat();
double[] features = new double[reader.getSize()];
Long start = System.currentTimeMillis();
for (int indexMol = 0; indexMol < reader.getSize(); indexMol++) {
if ((indexMol != 0) && (indexMol % 1000 == 0))
System.out.println("encodings/s = "
+ df.format(((double) indexMol) / ((double) ((System.currentTimeMillis() - start) / 1000)))
+ "\t(mappings so far = " + indexMol + ", @"
+ df.format(((double) indexMol / (double) reader.getSize()) * 100) + "%)");
IAtomContainer mol = reader.getMol(indexMol);
FeatureMap featureMap = new FeatureMap(fingerprinter.getFingerprint(mol));
features[indexMol] = featureMap.getKeySet().size();
}
Long end = System.currentTimeMillis();
Mean mean = new Mean();
StandardDeviation stdv = new StandardDeviation();
Max max = new Max();
Median median = new Median();
System.out.println("Time elapsed: " + (end - start) + " ms");
System.out.println("mol/s = " + df.format(reader.getSize() / ((double) (end - start) / 1000)));
System.out.println("no. features = " + df.format(mean.evaluate(features)) + "\t" + df.format(stdv.evaluate(features)));
System.out.println("Max = " + df.format(max.evaluate(features)));
System.out.println("Median = " + df.format(median.evaluate(features)));
}
示例4: getStandardDeviation
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
@Override
public double getStandardDeviation() {
StandardDeviation sdev = new StandardDeviation();
for (OperationRun r : this.runs) {
sdev.increment(r.getRuntime());
}
return sdev.getResult();
}
示例5: getStandardDeviation
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
@Override
public double getStandardDeviation() {
StandardDeviation sdev = new StandardDeviation();
for (OperationMixRun r : this.runs) {
sdev.increment(r.getTotalRuntime());
}
return sdev.getResult();
}
示例6: performCalculation
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
private void performCalculation(double[] values, int type) {
Mean meanCalculator = new Mean();
double mean = meanCalculator.evaluate(values);
Max maxCalculator = new Max();
double max = maxCalculator.evaluate(values);
Min minCalculator = new Min();
double min = minCalculator.evaluate(values);
StandardDeviation standardDeviationCalculator = new StandardDeviation();
double stdDeviation = standardDeviationCalculator.evaluate(values);
if (type == MotifStats.WORKFLOW) {
MotifStats.setMinWorkflowAppearance(min);
MotifStats.setMaxWorkflowAppearance(max);
MotifStats.setMeanWorkflowAppearance(mean);
MotifStats.setStdDeviationWorkflowUsage(stdDeviation);
} else if (type == MotifStats.USAGE) {
MotifStats.setMinUsage(min);
MotifStats.setMaxUsage(max);
MotifStats.setMeanUsage(mean);
MotifStats.setStdDeviationUsage(stdDeviation);
} else if (type == MotifStats.MSP) {
MotifStats.setMinMSP(min);
MotifStats.setMaxMSP(max);
MotifStats.setMeanMSP(mean);
MotifStats.setStdDeviationMSP(stdDeviation);
}
}
示例7: initializeAggregates
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
public void initializeAggregates(Collection<Double> valuesToNormalizeOverController)
{
ResizableDoubleArray tmpDoubleValues = new ResizableDoubleArray();
for (Double value : valuesToNormalizeOverController) {
tmpDoubleValues.addElement(value);
}
_stdDev = new StandardDeviation().evaluate(tmpDoubleValues.getElements());
_mean = new Mean().evaluate(tmpDoubleValues.getElements());
_initialized = true;
}
示例8: normalize
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
/**
* Normalizes the data to mean 0 and standard deviation 1. This method
* discards all instances that cannot be normalized, i.e. they have the same
* value for all attributes.
*
* @param data
* @return
*/
private Vector<TaggedInstance> normalize(Dataset data) {
Vector<TaggedInstance> out = new Vector<TaggedInstance>();
for (int i = 0; i < data.size(); i++) {
Double[] old = data.instance(i).values().toArray(new Double[0]);
double[] conv = new double[old.length];
for (int j = 0; j < old.length; j++) {
conv[j] = old[j];
}
Mean m = new Mean();
double MU = m.evaluate(conv);
// System.out.println("MU = "+MU);
StandardDeviation std = new StandardDeviation();
double SIGM = std.evaluate(conv, MU);
// System.out.println("SIGM = "+SIGM);
if (!MathUtils.eq(SIGM, 0)) {
double[] val = new double[old.length];
for (int j = 0; j < old.length; j++) {
val[j] = (float) ((old[j] - MU) / SIGM);
}
// System.out.println("VAL "+i+" = "+Arrays.toString(val));
out.add(new TaggedInstance(new DenseInstance(val, data.instance(i).classValue()), i));
}
}
// System.out.println("FIRST = "+out.get(0));
return out;
}
示例9: testHelixExternalViewBasedRoutingTable
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
@Test
public void testHelixExternalViewBasedRoutingTable() throws Exception {
String tableName = "testTable_OFFLINE";
String fileName = RandomRoutingTableTest.class.getClassLoader().getResource("SampleExternalView.json").getFile();
System.out.println(fileName);
InputStream evInputStream = new FileInputStream(fileName);
ZNRecordSerializer znRecordSerializer = new ZNRecordSerializer();
ZNRecord externalViewRecord = (ZNRecord) znRecordSerializer.deserialize(IOUtils.toByteArray(evInputStream));
int totalRuns = 10000;
RoutingTableBuilder routingStrategy = new BalancedRandomRoutingTableBuilder(10);
HelixExternalViewBasedRouting routingTable = new HelixExternalViewBasedRouting(routingStrategy, null, null, null);
ExternalView externalView = new ExternalView(externalViewRecord);
routingTable.markDataResourceOnline(tableName, externalView, new ArrayList<InstanceConfig>());
double[] globalArrays = new double[9];
for (int numRun = 0; numRun < totalRuns; ++numRun) {
RoutingTableLookupRequest request = new RoutingTableLookupRequest(tableName);
Map<ServerInstance, SegmentIdSet> serversMap = routingTable.findServers(request);
TreeSet<ServerInstance> serverInstances = new TreeSet<ServerInstance>(serversMap.keySet());
int i = 0;
double[] arrays = new double[9];
for (ServerInstance serverInstance : serverInstances) {
globalArrays[i] += serversMap.get(serverInstance).getSegments().size();
arrays[i++] = serversMap.get(serverInstance).getSegments().size();
}
for (int j = 0; i < arrays.length; ++j) {
Assert.assertTrue(arrays[j] / totalRuns <= 31);
Assert.assertTrue(arrays[j] / totalRuns >= 28);
}
//System.out.println(Arrays.toString(arrays) + " : " + new StandardDeviation().evaluate(arrays) + " : " + new Mean().evaluate(arrays));
}
for (int i = 0; i < globalArrays.length; ++i) {
Assert.assertTrue(globalArrays[i] / totalRuns <= 31);
Assert.assertTrue(globalArrays[i] / totalRuns >= 28);
}
System.out.println(Arrays.toString(globalArrays) + " : " + new StandardDeviation().evaluate(globalArrays) + " : "
+ new Mean().evaluate(globalArrays));
}
示例10: main
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
final double threshold = args.length == 0 ? 2.0 : Double
.parseDouble(args[0]);
Topology t = new Topology("StandardDeviationFilter");
final Random rand = new Random();
// Produce a stream of random double values with a normal
// distribution, mean 0.0 and standard deviation 1.
TStream<Double> values = t.limitedSource(new Supplier<Double>() {
private static final long serialVersionUID = 1L;
@Override
public Double get() {
return rand.nextGaussian();
}
}, 100000);
/*
* Filters the values based on calculating the mean and standard
* deviation from the incoming data. In this case only outliers are
* present in the output stream outliers. A outlier is defined as one
* more than (threshold*standard deviation) from the mean.
*
* This demonstrates an anonymous functional logic class that is
* stateful. The two fields mean and sd maintain their values across
* multiple invocations of the test method, that is for multiple tuples.
*
* Note both Mean & StandardDeviation classes are serializable.
*/
TStream<Double> outliers = values.filter(new Predicate<Double>() {
private static final long serialVersionUID = 1L;
private final Mean mean = new Mean();
private final StandardDeviation sd = new StandardDeviation();
@Override
public boolean test(Double tuple) {
mean.increment(tuple);
sd.increment(tuple);
double multpleSd = threshold * sd.getResult();
double absMean = Math.abs(mean.getResult());
double absTuple = Math.abs(tuple);
return absTuple > absMean + multpleSd;
}
});
outliers.print();
StreamsContextFactory.getEmbedded().submit(t).get();
}
示例11: Stat
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
public Stat() {
this.devAlgorithm = new StandardDeviation();
}
示例12: calculateStandardDeviation
import org.apache.commons.math.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
private static double calculateStandardDeviation(double[] values) {
StandardDeviation dev = new StandardDeviation();
return dev.evaluate(values);
}