本文整理汇总了Java中org.apache.commons.math3.stat.descriptive.SummaryStatistics类的典型用法代码示例。如果您正苦于以下问题:Java SummaryStatistics类的具体用法?Java SummaryStatistics怎么用?Java SummaryStatistics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SummaryStatistics类属于org.apache.commons.math3.stat.descriptive包,在下文中一共展示了SummaryStatistics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStats
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
private static Stats getStats(FloatColumn values, SummaryStatistics summaryStatistics) {
Stats stats = new Stats("Column: " + values.name());
stats.min = (float) summaryStatistics.getMin();
stats.max = (float) summaryStatistics.getMax();
stats.n = summaryStatistics.getN();
stats.sum = summaryStatistics.getSum();
stats.variance = summaryStatistics.getVariance();
stats.populationVariance = summaryStatistics.getPopulationVariance();
stats.quadraticMean = summaryStatistics.getQuadraticMean();
stats.geometricMean = summaryStatistics.getGeometricMean();
stats.mean = summaryStatistics.getMean();
stats.standardDeviation = summaryStatistics.getStandardDeviation();
stats.sumOfLogs = summaryStatistics.getSumOfLogs();
stats.sumOfSquares = summaryStatistics.getSumsq();
stats.secondMoment = summaryStatistics.getSecondMoment();
return stats;
}
示例2: ChronoFrequency
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
public ChronoFrequency(@NotNull ChronoUnit chronoUnit, int chronoSeriesPosition,
long minimumFrequency, long maximumFrequency, @NotNull Instant lastOccurrenceTimestamp) {
super(chronoSeriesPosition);
this.chronoUnit = requireNonNull(chronoUnit);
this.frequencyStatistics = new SummaryStatistics();
this.frequencyStatistics.addValue(minimumFrequency);
if (minimumFrequency != maximumFrequency) {
this.frequencyStatistics.addValue(maximumFrequency);
}
this.lastOccurrenceTimestamp = requireNonNull(lastOccurrenceTimestamp);
if (minimumFrequency < 0 || maximumFrequency < 0) {
throw new IllegalArgumentException("Minimum and maximum frequency must be greater than zero");
} else if (minimumFrequency > maximumFrequency || maximumFrequency < minimumFrequency) {
throw new IllegalArgumentException("Invalid minimum and maximum frequency combination");
}
}
示例3: getAggregateStats
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
public void getAggregateStats(double[] values1, double[] values2){
AggregateSummaryStatistics aggregate = new AggregateSummaryStatistics();
SummaryStatistics firstSet = aggregate.createContributingStatistics();
SummaryStatistics secondSet = aggregate.createContributingStatistics();
for(int i = 0; i < values1.length; i++) {
firstSet.addValue(values1[i]);
}
for(int i = 0; i < values2.length; i++) {
secondSet.addValue(values2[i]);
}
double sampleSum = aggregate.getSum();
double sampleMean = aggregate.getMean();
double sampleStd= aggregate.getStandardDeviation();
System.out.println(sampleSum + "\t" + sampleMean + "\t" + sampleStd);
}
示例4: computeStats
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
private void computeStats() {
SummaryStatistics centroidStats = new SummaryStatistics();
SummaryStatistics edgeStats = new SummaryStatistics();
for (IFeature poi : pois) {
centroidStats.addValue(getDistToCentroid().get(poi));
edgeStats.addValue(getDistToEdge().get(poi));
}
meanDistanceCentroid = centroidStats.getMean();
stdDistanceCentroid = centroidStats.getStandardDeviation();
minDistanceCentroid = centroidStats.getMin();
maxDistanceCentroid = centroidStats.getMax();
meanDistanceEdge = edgeStats.getMean();
stdDistanceEdge = edgeStats.getStandardDeviation();
minDistanceEdge = edgeStats.getMin();
maxDistanceEdge = edgeStats.getMax();
}
示例5: getEdges
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
private static FloatVector getEdges(MultiImage img) {
SummaryStatistics[] stats = new SummaryStatistics[256];
for (int i = 0; i < 256; ++i) {
stats[i] = new SummaryStatistics();
}
List<Boolean> edgePixels = EdgeImg.getEdgePixels(img,
new ArrayList<Boolean>(img.getWidth() * img.getHeight()));
ArrayList<LinkedList<Boolean>> partition = GridPartitioner.partition(edgePixels, img.getWidth(),
img.getHeight(), 16, 16);
for (int i = 0; i < partition.size(); ++i) {
LinkedList<Boolean> edge = partition.get(i);
SummaryStatistics stat = stats[i];
for (boolean b : edge) {
stat.addValue(b ? 1 : 0);
}
}
float[] f = new float[256];
for (int i = 0; i < 256; ++i) {
f[i] = (float) stats[i].getMean();
}
return new FloatVectorImpl(f);
}
示例6: getEdges
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
private static FloatVector getEdges(MultiImage img) {
SummaryStatistics[] stats = new SummaryStatistics[64];
for (int i = 0; i < 64; ++i) {
stats[i] = new SummaryStatistics();
}
List<Boolean> edgePixels = EdgeImg.getEdgePixels(img,
new ArrayList<Boolean>(img.getWidth() * img.getHeight()));
ArrayList<LinkedList<Boolean>> partition = ARPartioner.partition(edgePixels, img.getWidth(),
img.getHeight(), 8, 8);
for (int i = 0; i < partition.size(); ++i) {
LinkedList<Boolean> edge = partition.get(i);
SummaryStatistics stat = stats[i];
for (boolean b : edge) {
stat.addValue(b ? 1 : 0);
}
}
float[] f = new float[64];
for (int i = 0; i < 64; ++i) {
f[i] = (float) stats[i].getMean();
}
return new FloatVectorImpl(f);
}
示例7: getFeatures
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
/**
* Returns a list of feature vectors given a SegmentContainer.
*
* @param segment SegmentContainer for which to calculate the feature vectors.
* @return List of HPCP Shingle feature vectors.
*/
private List<float[]> getFeatures(SegmentContainer segment) {
/* Create STFT; If this fails, return empty list. */
Pair<Integer,Integer> parameters = FFTUtil.parametersForDuration(segment.getSamplingrate(), WINDOW_SIZE);
STFT stft = segment.getSTFT(parameters.first,(parameters.first - 2*parameters.second)/2, parameters.second, new HanningWindow());
if (stft == null) {
return new ArrayList<>();
}
HPCP hpcps = new HPCP(this.resolution, this.min_frequency, this.max_frequency);
hpcps.addContribution(stft);
int vectors = Math.max(hpcps.size() - SHINGLE_SIZE, 1);
final SummaryStatistics statistics = new SummaryStatistics();
List<Pair<Double, float[]>> features = new ArrayList<>(vectors);
for (int n = 0; n < vectors; n++) {
Pair<Double, float[]> feature = this.getHPCPShingle(hpcps, n);
features.add(feature);
statistics.addValue(feature.first);
}
final double threshold = 0.25*statistics.getGeometricMean();
return features.stream().filter(f -> (f.first > threshold)).map(f -> f.second).collect(Collectors.toList());
}
示例8: calcClusterMeanInfo
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
private double calcClusterMeanInfo(Set<Integer> members) throws AdeInternalException {
if (members.size() == 1){
return 0;
}
final SummaryStatistics sumS = new SummaryStatistics();
for (int i : members){
for (int j : members) {
if (i <= j){
continue;
}
double v;
v = m_informationMat.get(i, j);
if (!Double.isNaN(v)){
sumS.addValue(v);
}
}
}
final double res = sumS.getMean();
if (Double.isNaN(res)){
return 0;
}
return res;
}
示例9: init
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
@Override
public void init(ProcessContext ctx) throws Exception {
super.init(ctx);
histPanel = new BarPlotPanel(drawErrors, title);
frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(histPanel, BorderLayout.CENTER);
frame.setSize(width, height);
frame.setVisible(true);
for (String key : keys) {
summaryStatisticsHashMap.put(key, new SummaryStatistics());
}
// frame.setTitle(title);
if (keys == null) {
log.error("The keys paramter was null. Did you set it in the .xml file?");
}
}
示例10: processMatchingData
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
@Override
public Data processMatchingData(Data data) {
DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset();
for (String key : keys) {
if (data.containsKey(key)) {
String val = data.get(key).toString();
double d = Double.parseDouble(val);
SummaryStatistics ss = summaryStatisticsHashMap.get(key);
ss.addValue(d);
dataset.add(ss.getMean(), ss.getStandardDeviation(), " ", key);
} else {
log.warn("The key " + key + " does not exist in the Event");
}
}
histPanel.setDataset(dataset);
histPanel.getPreferredSize();
return data;
}
示例11: anovaStats
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
/**
* This method calls the method that actually does the calculations (except
* P-value).
*
* @param categoryData
* <code>Collection</code> of <code>double[]</code> arrays each
* containing data for one category
* @return computed AnovaStats
* @throws NullArgumentException
* if <code>categoryData</code> is <code>null</code>
* @throws DimensionMismatchException
* if the length of the <code>categoryData</code> array is less
* than 2 or a contained <code>double[]</code> array does not
* contain at least two values
*/
private AnovaStats anovaStats(final Collection<double[]> categoryData)
throws NullArgumentException, DimensionMismatchException {
MathUtils.checkNotNull(categoryData);
final Collection<SummaryStatistics> categoryDataSummaryStatistics =
new ArrayList<SummaryStatistics>(categoryData.size());
// convert arrays to SummaryStatistics
for (final double[] data : categoryData) {
final SummaryStatistics dataSummaryStatistics = new SummaryStatistics();
categoryDataSummaryStatistics.add(dataSummaryStatistics);
for (final double val : data) {
dataSummaryStatistics.addValue(val);
}
}
return anovaStats(categoryDataSummaryStatistics, false);
}
示例12: delegateGetBucketForString
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
public static RunStats delegateGetBucketForString(int buckets) throws FileNotFoundException, Exception
{
Long startTime = System.currentTimeMillis();
PrimaryIndexBucketGeneratorImpl ibg = new PrimaryIndexBucketGeneratorImpl(FieldDataType.TEXT, buckets);
PrimaryIndexBucketLocatorImpl locator = new PrimaryIndexBucketLocatorImpl(ibg.generateBuckets(), null, null, null, null, null, null, null, null);
logger.debug("test to getBucket for the bucket distribution");
String file = "/MostCommon20kEnglishWords.txt";
String englishFile = Utils.readFile(file);
String[] englishLines = englishFile.split("\n");
HashMap<Long, List<Object>> hm = new HashMap<>();
SummaryStatistics stats = new SummaryStatistics();
for (String line : englishLines)
{
line = line.trim();
Long bucketId = locator.getBucket(line, FieldDataType.TEXT);
calculate(hm, stats, bucketId, line);
}
Long runTime = System.currentTimeMillis() - startTime;
RunStats runStats = new RunStats("BucketForStrings", FieldDataType.TEXT, runTime, stats, hm);
logger.debug(runStats.toString());
return runStats;
}
示例13: delegateGetBucketForBoolean
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
/**
* checks the Bucket Distribution for the Boolean values
*
* @throws IndexParseFieldException
*/
public static RunStats delegateGetBucketForBoolean(int buckets) throws Exception
{
Long startTime = System.currentTimeMillis();
PrimaryIndexBucketGeneratorImpl ibg = new PrimaryIndexBucketGeneratorImpl(FieldDataType.BOOLEAN, buckets);
PrimaryIndexBucketLocatorImpl locator = new PrimaryIndexBucketLocatorImpl(null, null, null, null, ibg.generateBuckets(), null, null, null, null);
logger.debug("Test to getBucket for the bucket distribution on Boolean values");
HashMap<Long, List<Object>> hm = new HashMap<>();
SummaryStatistics stats = new SummaryStatistics();
for (int i = 0; i < 20000; i++)
{
Boolean randomBoolean = RandomUtils.nextBoolean();
Long bucketId = locator.getBucket(randomBoolean, FieldDataType.BOOLEAN);
TestUtils.calculate(hm, stats, bucketId, randomBoolean);
}
Long runTime = System.currentTimeMillis() - startTime;
RunStats runStats = new RunStats("BucketForBoolean", FieldDataType.BOOLEAN, runTime, stats, hm);
logger.debug(runStats.toString());
return runStats;
}
示例14: delegateGetBucketForUuids
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
/**
* Test to check the Bucket Distribution for the UUID values
*
* @throws IndexParseFieldException
*/
public static RunStats delegateGetBucketForUuids(int buckets) throws Exception
{
Long startTime = System.currentTimeMillis();
PrimaryIndexBucketGeneratorImpl ibg = new PrimaryIndexBucketGeneratorImpl(FieldDataType.UUID, buckets);
PrimaryIndexBucketLocatorImpl locator = new PrimaryIndexBucketLocatorImpl(null, null, null, null, null, ibg.generateBuckets(), null, null, null);
logger.debug("test to getBucket for the bucket distribution on UUIDs");
HashMap<Long, List<Object>> hm = new HashMap<>();
SummaryStatistics stats = new SummaryStatistics();
UUID[] uuid = new UUID[10000];
for (int i = 0; i < 10000; i++)
{
uuid[i] = UUID.randomUUID();
}
for (int inputUuid = 0; inputUuid < 10000; inputUuid++)
{
Long bucketId = locator.getBucket(uuid[inputUuid], FieldDataType.UUID);
calculate(hm, stats, bucketId, inputUuid);
}
Long runTime = System.currentTimeMillis() - startTime;
RunStats runStats = new RunStats("BucketForUUIDs", FieldDataType.UUID, runTime, stats, hm);
logger.debug(runStats.toString());
return runStats;
}
示例15: delegateGetBucketForIntegers
import org.apache.commons.math3.stat.descriptive.SummaryStatistics; //导入依赖的package包/类
/**
* Test to check the Bucket Distribution for the common Integer values
*
* @throws IndexParseFieldException
*/
public static RunStats delegateGetBucketForIntegers(int buckets) throws Exception
{
Long startTime = System.currentTimeMillis();
PrimaryIndexBucketGeneratorImpl ibg = new PrimaryIndexBucketGeneratorImpl(FieldDataType.INTEGER, buckets);
PrimaryIndexBucketLocatorImpl locator = new PrimaryIndexBucketLocatorImpl(null, null, null, ibg.generateBuckets(), null, null, null, null, null);
logger.debug("test to getBucket for the bucket distribution");
HashMap<Long, List<Object>> hm = new HashMap<>();
SummaryStatistics stats = new SummaryStatistics();
for (int inputInt = -2000000; inputInt < 2000000; inputInt++)
{
Long bucketId = locator.getBucket(inputInt, FieldDataType.INTEGER);
calculate(hm, stats, bucketId, inputInt);
}
Long runTime = System.currentTimeMillis() - startTime;
RunStats runStats = new RunStats("BucketForIntegers", FieldDataType.INTEGER, runTime, stats, hm);
logger.debug(runStats.toString());
return runStats;
}