本文整理汇总了Java中org.apache.commons.math.stat.descriptive.DescriptiveStatistics类的典型用法代码示例。如果您正苦于以下问题:Java DescriptiveStatistics类的具体用法?Java DescriptiveStatistics怎么用?Java DescriptiveStatistics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DescriptiveStatistics类属于org.apache.commons.math.stat.descriptive包,在下文中一共展示了DescriptiveStatistics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: frequencyToStatistics
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
public static DescriptiveStatistics frequencyToStatistics(Frequency frequency)
{
Iterator<Comparable<?>> comparableIterator = frequency.valuesIterator();
DescriptiveStatistics result = new DescriptiveStatistics();
while (comparableIterator.hasNext()) {
Comparable<?> next = comparableIterator.next();
long count = frequency.getCount(next);
for (int i = 0; i < count; i++) {
if (next instanceof Number) {
result.addValue(((Number) next).doubleValue());
}
}
}
return result;
}
示例2: getClusteringInfo
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
public String getClusteringInfo() {
StringBuffer sb = new StringBuffer();
sb.append("concept clustering:\n");
sb.append("mentions:\t");
if (this.groupedConcepts != null) {
int mentions = this.groupedConcepts.stream().mapToInt(x -> x.size()).sum();
sb.append(mentions);
} else {
sb.append("none");
}
sb.append("\n");
sb.append("concepts:\t");
sb.append(this.concepts.size());
sb.append("\n");
DescriptiveStatistics lengthStat = new DescriptiveStatistics();
for (List<Concept> cluster : this.groupedConcepts)
lengthStat.addValue(cluster.size());
sb.append("cluster size:\n");
sb.append(lengthStat);
return sb.toString();
}
示例3: getValues
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
/**
* @see org.apache.commons.math.stat.descriptive.DescriptiveStatistics#getValues()
*/
public double[] getValues() {
int length = list.size();
// If the window size is not INFINITE_WINDOW AND
// the current list is larger that the window size, we need to
// take into account only the last n elements of the list
// as definied by windowSize
if (windowSize != DescriptiveStatistics.INFINITE_WINDOW &&
windowSize < list.size())
{
length = list.size() - Math.max(0, list.size() - windowSize);
}
// Create an array to hold all values
double[] copiedArray = new double[length];
for (int i = 0; i < copiedArray.length; i++) {
copiedArray[i] = getElement(i);
}
return copiedArray;
}
示例4: getElement
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
/**
* @see org.apache.commons.math.stat.descriptive.DescriptiveStatistics#getElement(int)
*/
public double getElement(int index) {
double value = Double.NaN;
int calcIndex = index;
if (windowSize != DescriptiveStatistics.INFINITE_WINDOW &&
windowSize < list.size())
{
calcIndex = (list.size() - windowSize) + index;
}
try {
value = transformer.transform(list.get(calcIndex));
} catch (MathException e) {
e.printStackTrace();
}
return value;
}
示例5: testDescriptiveStatistics
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
/**
* Test DescriptiveStatistics - implementations that store full array of
* values and execute multi-pass algorithms
*/
public void testDescriptiveStatistics() throws Exception {
DescriptiveStatistics u = new DescriptiveStatistics();
loadStats("data/PiDigits.txt", u);
assertEquals("PiDigits: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("PiDigits: mean", mean, u.getMean(), 1E-14);
loadStats("data/Mavro.txt", u);
assertEquals("Mavro: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("Mavro: mean", mean, u.getMean(), 1E-14);
loadStats("data/Michelso.txt", u);
assertEquals("Michelso: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("Michelso: mean", mean, u.getMean(), 1E-14);
loadStats("data/NumAcc1.txt", u);
assertEquals("NumAcc1: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("NumAcc1: mean", mean, u.getMean(), 1E-14);
loadStats("data/NumAcc2.txt", u);
assertEquals("NumAcc2: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("NumAcc2: mean", mean, u.getMean(), 1E-14);
}
示例6: 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;
}
}
}
}
示例7: getCoprocessorExecutionStatistics
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
public Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics() {
Map<String, DescriptiveStatistics> results = new HashMap<String, DescriptiveStatistics>();
for (RegionEnvironment env : coprocessors) {
DescriptiveStatistics ds = new DescriptiveStatistics();
if (env.getInstance() instanceof RegionObserver) {
for (Long time : env.getExecutionLatenciesNanos()) {
ds.addValue(time);
}
// Ensures that web ui circumvents the display of NaN values when there are zero samples.
if (ds.getN() == 0) {
ds.addValue(0);
}
results.put(env.getInstance().getClass().getSimpleName(), ds);
}
}
return results;
}
示例8: testTakedown
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
@Override
protected void testTakedown() throws IOException {
if (this.gets != null && this.gets.size() > 0) {
this.table.get(gets);
this.gets.clear();
}
super.testTakedown();
if (opts.reportLatency) {
Arrays.sort(times);
DescriptiveStatistics ds = new DescriptiveStatistics();
for (double t : times) {
ds.addValue(t);
}
LOG.info("randomRead latency log (ms), on " + times.length + " measures");
LOG.info("99.9999% = " + ds.getPercentile(99.9999d));
LOG.info(" 99.999% = " + ds.getPercentile(99.999d));
LOG.info(" 99.99% = " + ds.getPercentile(99.99d));
LOG.info(" 99.9% = " + ds.getPercentile(99.9d));
LOG.info(" 99% = " + ds.getPercentile(99d));
LOG.info(" 95% = " + ds.getPercentile(95d));
LOG.info(" 90% = " + ds.getPercentile(90d));
LOG.info(" 80% = " + ds.getPercentile(80d));
LOG.info("Standard Deviation = " + ds.getStandardDeviation());
LOG.info("Mean = " + ds.getMean());
}
}
示例9: getSummaryReport
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
@Override
public String getSummaryReport() {
final StringBuilder outBuffer = new StringBuilder();
final DescriptiveStatistics ds = computeStats();
outBuffer.append("Aggregate [email protected]" + N + " Statistics:\n");
outBuffer.append(String.format("%-15s\t%6d\n", "num_q", ds.getN()));
outBuffer.append(String.format("%-15s\t%6.4f\n", "min", ds.getMin()));
outBuffer.append(String.format("%-15s\t%6.4f\n", "max", ds.getMax()));
outBuffer.append(String.format("%-15s\t%6.4f\n", "mean", ds.getMean()));
outBuffer.append(String.format("%-15s\t%6.4f\n", "std dev", ds.getStandardDeviation()));
outBuffer.append(String.format("%-15s\t%6.4f\n", "median", ds.getPercentile(50)));
outBuffer.append(String.format("%-15s\t%6.4f\n", "skewness", ds.getSkewness()));
outBuffer.append(String.format("%-15s\t%6.4f\n", "kurtosis", ds.getKurtosis()));
return outBuffer.toString();
}
示例10: 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;
}
示例11: getValues
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public double[] getValues() {
int length = list.size();
// If the window size is not INFINITE_WINDOW AND
// the current list is larger that the window size, we need to
// take into account only the last n elements of the list
// as definied by windowSize
if (windowSize != DescriptiveStatistics.INFINITE_WINDOW &&
windowSize < list.size())
{
length = list.size() - Math.max(0, list.size() - windowSize);
}
// Create an array to hold all values
double[] copiedArray = new double[length];
for (int i = 0; i < copiedArray.length; i++) {
copiedArray[i] = getElement(i);
}
return copiedArray;
}
示例12: getElement
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public double getElement(int index) {
double value = Double.NaN;
int calcIndex = index;
if (windowSize != DescriptiveStatistics.INFINITE_WINDOW &&
windowSize < list.size())
{
calcIndex = (list.size() - windowSize) + index;
}
try {
value = transformer.transform(list.get(calcIndex));
} catch (MathException e) {
e.printStackTrace();
}
return value;
}
示例13: getN
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public long getN() {
int n = 0;
if (windowSize != DescriptiveStatistics.INFINITE_WINDOW) {
if (list.size() > windowSize) {
n = windowSize;
} else {
n = list.size();
}
} else {
n = list.size();
}
return n;
}
示例14: testDescriptiveStatistics
import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入依赖的package包/类
/**
* Test DescriptiveStatistics - implementations that store full array of
* values and execute multi-pass algorithms
*/
public void testDescriptiveStatistics() throws Exception {
DescriptiveStatistics u = new DescriptiveStatistics();
loadStats("data/PiDigits.txt", u);
assertEquals("PiDigits: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("PiDigits: mean", mean, u.getMean(), 1E-14);
loadStats("data/Mavro.txt", u);
assertEquals("Mavro: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("Mavro: mean", mean, u.getMean(), 1E-14);
loadStats("data/Michelso.txt", u);
assertEquals("Michelso: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("Michelso: mean", mean, u.getMean(), 1E-14);
loadStats("data/NumAcc1.txt", u);
assertEquals("NumAcc1: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("NumAcc1: mean", mean, u.getMean(), 1E-14);
loadStats("data/NumAcc2.txt", u);
assertEquals("NumAcc2: std", std, u.getStandardDeviation(), 1E-14);
assertEquals("NumAcc2: mean", mean, u.getMean(), 1E-14);
}
示例15: 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;
}