本文整理汇总了Java中org.apache.commons.math.stat.descriptive.DescriptiveStatistics.getStandardDeviation方法的典型用法代码示例。如果您正苦于以下问题:Java DescriptiveStatistics.getStandardDeviation方法的具体用法?Java DescriptiveStatistics.getStandardDeviation怎么用?Java DescriptiveStatistics.getStandardDeviation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math.stat.descriptive.DescriptiveStatistics
的用法示例。
在下文中一共展示了DescriptiveStatistics.getStandardDeviation方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scale
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
private void scale(double[][] peakList) {
DescriptiveStatistics stdDevStats = new DescriptiveStatistics();
for (int columns = 0; columns < peakList.length; columns++) {
stdDevStats.clear();
for (int row = 0; row < peakList[columns].length; row++) {
if (!Double.isInfinite(peakList[columns][row])
&& !Double.isNaN(peakList[columns][row])) {
stdDevStats.addValue(peakList[columns][row]);
}
}
double stdDev = stdDevStats.getStandardDeviation();
for (int row = 0; row < peakList[columns].length; row++) {
if (stdDev != 0) {
peakList[columns][row] = peakList[columns][row] / stdDev;
}
}
}
}
示例2: computeStatistics
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**
* Compute the current aggregate statistics of the
* accumulated results.
*
* @return the current aggregate statistics
*/
public AggregateStatistics computeStatistics() {
DescriptiveStatistics accuracy = new DescriptiveStatistics();
DescriptiveStatistics errorRate = new DescriptiveStatistics();
for (CMResult<CLASS> result : matrices) {
ConfusionMatrix<CLASS> m = result.getMatrix();
accuracy.addValue(m.getAccuracy());
errorRate.addValue(m.getErrorRate());
}
AggregateStatistics s = new AggregateStatistics();
s.meanAccuracy = accuracy.getMean();
s.stddevAccuracy = accuracy.getStandardDeviation();
s.meanErrorRate = errorRate.getMean();
s.stddevErrorRate = errorRate.getStandardDeviation();
return s;
}
示例3: normalize
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**
* Normalize (standardize) the series, so in the end it is having a mean of 0 and a standard deviation of 1.
*
* @param sample Sample to normalize.
* @return normalized (standardized) sample.
* @since 2.2
*/
public static double[] normalize(final double[] sample) {
DescriptiveStatistics stats = new DescriptiveStatistics();
// Add the data from the series to stats
for (int i = 0; i < sample.length; i++) {
stats.addValue(sample[i]);
}
// Compute mean and standard deviation
double mean = stats.getMean();
double standardDeviation = stats.getStandardDeviation();
// initialize the standardizedSample, which has the same length as the sample
double[] standardizedSample = new double[sample.length];
for (int i = 0; i < sample.length; i++) {
// z = (x- mean)/standardDeviation
standardizedSample[i] = (sample[i] - mean) / standardDeviation;
}
return standardizedSample;
}
示例4: APARegionStatistics
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public APARegionStatistics(RealMatrix data, int regionWidth) {
int max = data.getColumnDimension();
int midPoint = max / 2;
double centralVal = data.getEntry(midPoint, midPoint);
/** NOTE - indices are inclusive in java, but in python the second index is not inclusive */
peak2mean = centralVal / ((sum(data.getData()) - centralVal) / (data.getColumnDimension() - 1));
double avgUL = mean(data.getSubMatrix(0, regionWidth - 1, 0, regionWidth - 1).getData());
peak2UL = centralVal / avgUL;
avgUR = mean(data.getSubMatrix(0, regionWidth - 1, max - regionWidth, max - 1).getData());
peak2UR = centralVal / avgUR;
double avgLL = mean(data.getSubMatrix(max - regionWidth, max - 1, 0, regionWidth - 1).getData());
peak2LL = centralVal / avgLL;
double avgLR = mean(data.getSubMatrix(max - regionWidth, max - 1, max - regionWidth, max - 1).getData());
peak2LR = centralVal / avgLR;
DescriptiveStatistics yStats = statistics(data.getSubMatrix(max - regionWidth, max - 1, 0, regionWidth - 1).getData());
ZscoreLL = (centralVal - yStats.getMean()) / yStats.getStandardDeviation();
}
示例5: buildFeatureObject
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public Feature buildFeatureObject(DescriptiveStatistics summary,String name){
double geometricMean = summary.getGeometricMean();
double kurtosis = summary.getKurtosis();
double max = summary.getMax();
double mean = summary.getMean();
double min = summary.getMin();
double skewness = summary.getSkewness();
double standardDeviation = summary.getStandardDeviation();
double sum = summary.getSum();
double sumsq = summary.getSumsq();
double variance = summary.getVariance();
double[] values = summary.getValues();
Feature feature=new Feature(name, name, null, mean, variance, skewness);
LOG.log(Level.INFO, summary.toString());
return feature;
}
示例6: drawNormalDistributionChart
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public void drawNormalDistributionChart(double[] values) {
DescriptiveStatistics stats = new DescriptiveStatistics();
// Add the data from the array
for (int i = 0; i < values.length; i++) {
stats.addValue(values[i]);
}
// Compute some statistics
double mean = stats.getMean();
double std = stats.getStandardDeviation();
double skewness = stats.getSkewness();
double variance = stats.getVariance();
double kurtosis = stats.getKurtosis();
System.out.println(mean + "\t" + std + "\t" + skewness + "\t" + variance + "\t" + kurtosis);
stats.clear();
}
示例7: AnalysisResultsModel
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public AnalysisResultsModel(ArrayList<Double> firesPerCenturyPerSim, SegmentModel segment, int numberOfSamples) {
this.segment = segment;
this.numberOfSamples = numberOfSamples;
// Generate Apache Commons descriptive statistics
stats = new DescriptiveStatistics();
for (Double val : firesPerCenturyPerSim)
{
stats.addValue(val);
}
meanEventsPerCentury = stats.getMean();
std = stats.getStandardDeviation();
median = stats.getPercentile(50);
CI95 = STDEV_MULTIPLIER_FOR_95 * std;
CI99 = STDEV_MULTIPLIER_FOR_99 * std;
// Generate Weibull stats
Weibull weibull = new Weibull(firesPerCenturyPerSim);
weibullMean = weibull.getMean();
weibullMedian = weibull.getMedian();
// TODO Elena to check
weibullCI95Lower = weibull.getExceedencePercentile(5.0);
weibullCI95Upper = weibull.getExceedencePercentile(95.0);
weibullCI99 = weibull.getExceedencePercentile(99.0) - weibullMedian;
}
示例8: getSkeletonCategoryFromCropper1979
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
private Integer getSkeletonCategoryFromCropper1979(Integer value, DescriptiveStatistics windowStats, Double criticalLevel)
{
Integer skeletonCategory = 0;
if(criticalLevel==null) criticalLevel = 0.5;
double mean = windowStats.getMean();
double stdev = windowStats.getStandardDeviation();
double smallRingThreshold = mean-(stdev*criticalLevel);
int min = (int) windowStats.getMin();
if(value == min)
{
skeletonCategory = 10;
}
else if(value > smallRingThreshold)
{
skeletonCategory = 0;
}
else
{
Integer range = (int) (smallRingThreshold - min);
Integer categoryStepSize = range / 10;
skeletonCategory = (int) (0-((value-smallRingThreshold)/categoryStepSize));
}
return skeletonCategory;
}
示例9: getFeatureMatchDistribution
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public static double getFeatureMatchDistribution(GraphDatabaseService db, Long patternId)
{
Transaction tx = db.beginTx();
Node startNode = db.getNodeById(patternId);
// Feature match distribution
List<Double> matches = IteratorUtil.asCollection(db.traversalDescription()
.depthFirst()
.relationships(withName("HAS_CLASS"), Direction.OUTGOING)
.evaluator(Evaluators.fromDepth(1))
.evaluator(Evaluators.toDepth(1))
.traverse(startNode)
.relationships())
.stream()
.map(p -> ((Integer)p.getProperty("matches")).doubleValue())
.collect(Collectors.toList());
tx.success();
tx.close();
double variance = 1.0;
if(matches.size() > 1) {
Double[] matchArr = matches.toArray(new Double[matches.size()]);
// Get the standard deviation
DescriptiveStatistics ds = new DescriptiveStatistics();
matches.forEach(m -> ds.addValue(m.doubleValue() / StatUtils.sum(ArrayUtils.toPrimitive(matchArr))));
variance = ds.getStandardDeviation();
}
return variance;
}
示例10: main
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
//String path = args[0];
String path = "/home/mgerlich/workspace-3.5/MetFusion2/testdata/Hill/results/2010-06-15_16-49-42/";
File dir = new File(path);
//File[] list = dir.listFiles(new MyFileFilter(".vec"));
File[] results = dir.listFiles(new MyFileFilter("_result.log"));
Arrays.sort(results);
//if (list.length != 102 || results.length != 102) {
if (results.length != 102) {
System.err.println("wrong number of results files - aborting...");
System.err.println("expected 102 - was " + results.length + " for _result.log files.");
//System.exit(-1);
}
else System.out.println("expected 102 results found :)");
String[] cids = new String[results.length];
int[] worstRanks = new int[results.length];
int[] threshRanks = new int[results.length];
int[] threshTiedRanks = new int[results.length];
int[] weightRanks = new int[results.length];
int[] weightTiedRanks = new int[results.length];
for (int i = 0; i < results.length; i++) {
File f = results[i];
System.out.println(f);
BufferedReader br = new BufferedReader(new FileReader(f));
String line = "";
while((line = br.readLine()) != null) {
/**
* String header = "## CID\tworstRank\tthresholdRank\tweightedRank\tthresholdTiedRank\tweightedTiedRank\n";
*/
if(line.startsWith("##") || line.startsWith("CID"))
continue;
String[] split = line.split("\t");
cids[i] = split[0];
worstRanks[i] = Integer.parseInt(split[1]);
threshRanks[i] = Integer.parseInt(split[2]);
weightRanks[i] = Integer.parseInt(split[3]);
threshTiedRanks[i] = Integer.parseInt(split[4]);
weightTiedRanks[i] = Integer.parseInt(split[5]);
}
}
// Get a DescriptiveStatistics instance
DescriptiveStatistics stats = new DescriptiveStatistics();
// Add the data from the array
for( int i = 0; i < threshTiedRanks.length; i++) {
stats.addValue(threshTiedRanks[i]);
}
// Compute some statistics
double mean = stats.getMean();
double std = stats.getStandardDeviation();
System.out.println("mean=" + mean + "\tsd=" + std);
// double mean2 = StatUtils.mean(weightTiedRanks);
// double std2 = StatUtils.variance(weightTiedRanks);
// double median = StatUtils.percentile(weightTiedRanks, 0.5);
//double median = stats.getMedian();
}