当前位置: 首页>>代码示例>>Java>>正文


Java DescriptiveStatistics.addValue方法代码示例

本文整理汇总了Java中org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.addValue方法的典型用法代码示例。如果您正苦于以下问题:Java DescriptiveStatistics.addValue方法的具体用法?Java DescriptiveStatistics.addValue怎么用?Java DescriptiveStatistics.addValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.stat.descriptive.DescriptiveStatistics的用法示例。


在下文中一共展示了DescriptiveStatistics.addValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: acrossLabels

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
@Override
public final DescriptiveStatistics acrossLabels(
		final List<? extends Predictions<? extends E[], ? extends Collection<? extends P>>>[] predictions) {
	final DescriptiveStatistics stats = new DescriptiveStatistics();
	for (final List<? extends Predictions<? extends E[], ? extends Collection<? extends P>>> predz : Check
			.size(predictions, 1, 9999999)) {
		for (final Predictions<? extends E[], ? extends Collection<? extends P>> preds : predz) {
			for (final double val : label(preds.getPredictions(),
					(E[][]) preds.getExpected(),
					preds.getWeights(),
					preds.getSamples(),
					preds.getLabelIndex()).getValues()) {
				stats.addValue(val);
			}
		}
	}
	Check.num(stats.getN(), 1, 999999999);
	return stats;
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:20,代码来源:AbstractIRFunction.java

示例2: acrossLabels

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
@Override
public DescriptiveStatistics acrossLabels(
		final List<? extends Predictions<? extends Number, ? extends Number>>[] predictions) {
	final DescriptiveStatistics stats = new DescriptiveStatistics();
	for (final List<? extends Predictions<? extends Number, ? extends Number>> predz : predictions) {
		for (final Predictions<? extends Number, ? extends Number> preds : predz) {
			final Number[] pred = preds.getPredictions();
			final Number[] exp = preds.getExpected();
			final int labelIndex = preds.getLabelIndex();
			for (int i = 0; i < pred.length; ++i) {
				if (exp[i] != null) {
					stats.addValue(instance(pred[i], exp[i], preds.getSample(i), labelIndex));
				}
			}
		}
	}
	return stats;
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:19,代码来源:MeanAbsoluteError.java

示例3: acrossLabels

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
@Override
public final DescriptiveStatistics acrossLabels(
		final List<? extends Predictions<? extends E, ? extends T>>[] predictions) {
	final DescriptiveStatistics stats = new DescriptiveStatistics();
	for (final List<? extends Predictions<? extends E, ? extends T>> predz : predictions) {
		for (final Predictions<? extends E, ? extends T> preds : predz) {
			for (final double val : label(preds.getPredictions(),
					preds.getExpected(),
					preds.getWeights(),
					preds.getSamples(),
					preds.getLabelIndex()).getValues()) {
				stats.addValue(val);
			}
		}
	}
	return stats;
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:18,代码来源:AbstractIndependentLabelsObjectiveFunction.java

示例4: findLocalMaxima

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**
 * Find local maxima in the spectrum and returns the indices of those maxima as integer
 * array.
 *
 * @param threshold Threshold for search. Values bellow that threshold won't be considered.
 * @return Array containing indices (zero-based) of local maxima.
 */
public List<Pair<Float, Double>> findLocalMaxima(double threshold, boolean significant) {
    List<Pair<Float,Double>> peaks = new ArrayList<>();
    for (int i=1;i<this.spectrum.length-1;i++) {
        if (this.spectrum[i] < threshold) {
          continue;
        }
        if (spectrum[i] > Math.max(spectrum[i+1], spectrum[i-1])) {
          peaks.add(this.get(i));
        }
    }

    if (significant) {
        DescriptiveStatistics statistics = new DescriptiveStatistics();
        for (Pair<Float, Double> peak : peaks) {
            statistics.addValue(peak.second);
        }
        final double mean = statistics.getMean();
        final double stddev = statistics.getStandardDeviation();
        peaks.removeIf(p -> p.second < (mean + stddev * 2));
    }

    return peaks;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:31,代码来源:Spectrum.java

示例5: statistics

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public ReflexValue statistics(List<ReflexValue> params) {
    if (params.size() != 1) {
        throw new ReflexException(-1, "statistics needs one list parameter");
    }
    if (!params.get(0).isList()) {
        throw new ReflexException(-1, "statistics needs one list parameter");
    }
    DescriptiveStatistics stats = new DescriptiveStatistics();
    List<ReflexValue> values = params.get(0).asList();
    for (ReflexValue v : values) {
        stats.addValue(v.asDouble());
    }
    Map<String, ReflexValue> ret = new HashMap<String, ReflexValue>();
    ret.put("mean", new ReflexValue(stats.getMean()));
    ret.put("std", new ReflexValue(stats.getStandardDeviation()));
    ret.put("median", new ReflexValue(stats.getPercentile(50)));
    return new ReflexValue(ret);
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:19,代码来源:ReflexStatistics.java

示例6: process

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
@Override
public Data process(Data item) {
    int[][] singlePulses = (int[][]) item.get(singlePulsesKey);
    double[] arrivalTimes = new double[singlePulses.length];

    for (int pix = 0; pix < singlePulses.length; pix++) {
        if (singlePulses[pix].length == 0) {
            arrivalTimes[pix] = 0.; // use zero instead of NaN - plotter likes no NaN
        } else {
            DescriptiveStatistics stat = new DescriptiveStatistics();
            for (int slice : singlePulses[pix]) {
                stat.addValue((double) slice);
            }
            arrivalTimes[pix] = stat.getPercentile(50);
        }
    }
    item.put(arrivalTimeKey, arrivalTimes);
    return item;
}
 
开发者ID:fact-project,项目名称:fact-tools,代码行数:20,代码来源:PhotonStream2ArrivalTime.java

示例7: normalize

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**
 * Normalize (standardize) the sample, so it is has 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;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:29,代码来源:StatUtils.java

示例8: testQuantiles

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
@Test
public void testQuantiles() {
    Random r = new Random(0);
    List<DataPoint> points = new ArrayList<>();
    DescriptiveStatistics stats = new DescriptiveStatistics();
    Distribution distribution = null;
    for(int i = 0; i < 100;++i) {
        double val = r.nextDouble()*1000;
        DataPoint dp = (new DataPoint(i, val, null, "foo"));
        points.add(dp);
        stats.addValue(val);
        if(distribution == null) {
            distribution = new Distribution(dp, ScalingFunctions.NONE, new GlobalStatistics());
        }
        else {
            distribution.addDataPoint(dp, ScalingFunctions.NONE);
        }
    }
    double realMedian = stats.getPercentile(50);
    double approxMedian = distribution.getMedian();
    System.out.println("mean and std dev: " + stats.getMean() + ", " + Math.sqrt(stats.getVariance()));
    System.out.println("Real : " + realMedian + ", approx: " + approxMedian);
    Assert.assertTrue(Math.abs(realMedian - approxMedian) < 5);
}
 
开发者ID:cestella,项目名称:streaming_outliers,代码行数:25,代码来源:DistributionTest.java

示例9: usingApacheCommons

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public void usingApacheCommons() {
    // Using Apache Commons to find mean
    Mean mean = new Mean();
    double average = mean.evaluate(testData);
    out.println("The mean is " + average);

    DescriptiveStatistics statTest
            = new SynchronizedDescriptiveStatistics();
    for (double num : testData) {
        statTest.addValue(num);
    }
    out.println("The mean is " + statTest.getMean());

}
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:15,代码来源:Main.java

示例10: usingApacaheCommonstoCalculateMedian

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public void usingApacaheCommonstoCalculateMedian() {
    // Using Apache Commons to find median
    double[] testData = {12.5, 18.3, 11.2, 19.0, 22.1, 14.3, 16.2, 12.5, 17.8, 16.5, 12.5};
    DescriptiveStatistics statTest
            = new SynchronizedDescriptiveStatistics();
    for (double num : testData) {
        statTest.addValue(num);
    }
    out.println("The median is " + statTest.getPercentile(50));
}
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:11,代码来源:Main.java

示例11: calculateAggregateResultFromAggregates

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public BigDecimal[] calculateAggregateResultFromAggregates(List<Observation> sourceObs) {
    BigDecimal[] result;
    DescriptiveStatistics stats = new DescriptiveStatistics();
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    int scale = 0;
    for (Observation obs : sourceObs) {
        Object input = obs.getResult();
        if (input instanceof List) {
            List list = (List) input;
            Number number = handleResult(list.get(0));
            scale = Math.max(getScale(number), scale);

            stats.addValue(number.doubleValue());
            min = Math.min(min, handleResult(list.get(1)).doubleValue());
            max = Math.max(max, handleResult(list.get(2)).doubleValue());
        } else {
            String type = input == null ? "null" : input.getClass().getName();
            LOGGER.error("Aggregate input of obs {} should be a List, not a {}", obs.getId(), type);
            throw new IllegalArgumentException("Expected List, got " + type);
        }
    }
    result = new BigDecimal[]{
        new BigDecimal(stats.getMean()).setScale(scale, RoundingMode.HALF_UP),
        new BigDecimal(min).setScale(scale, RoundingMode.HALF_UP),
        new BigDecimal(max).setScale(scale, RoundingMode.HALF_UP),
        new BigDecimal(stats.getStandardDeviation()).setScale(scale, RoundingMode.HALF_UP)
    };
    return result;
}
 
开发者ID:hylkevds,项目名称:SensorThingsProcessor,代码行数:31,代码来源:Aggregator.java

示例12: getDescStats

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public void getDescStats(double[] values){
	DescriptiveStatistics stats = new DescriptiveStatistics();
	for( int i = 0; i < values.length; i++) {
	        stats.addValue(values[i]);
	}
	double mean = stats.getMean();
	double std = stats.getStandardDeviation();
	double median = stats.getPercentile(50);
	System.out.println(mean + "\t" + std + "\t" + median);
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:11,代码来源:DescriptiveStats.java

示例13: testDescriptiveStatistics

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**
 * Creates an random double array, tests some descriptive statistics functions
 *
 * @throws Exception
 */
@Test
public void testDescriptiveStatistics() throws Exception {
    DescriptiveStatistics stats = new DescriptiveStatistics();
    for (int i = 0; i < 100; i++) {
        stats.addValue(Math.random());
    }

    System.out.println("Testing array: " + Arrays.toString(stats.getValues()));
    //Test mean function: mean should be equal to sum divided by length
    assertEquals(stats.getSum() / stats.getN(), stats.getMean(), 0.001);
    //Test variance and standard deviation: standard deviation should be equal to square root of variance
    assertEquals(Math.sqrt(stats.getVariance()), stats.getStandardDeviation(), 0.001);
}
 
开发者ID:jmueller95,项目名称:CORNETTO,代码行数:19,代码来源:ApacheMathTest.java

示例14: collectMoreTolData

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public List<DescriptiveStatistics> collectMoreTolData()
{
	List<DescriptiveStatistics> returnList = new ArrayList<>();
	DescriptiveStatistics tolstats = new DescriptiveStatistics();
	List<Double> toldata = collectThresholdALL();
	for (int t = 0; t < toldata.size(); t++)
	{
		tolstats.addValue(toldata.get(t));
	}

	DescriptiveStatistics natTolStats = new DescriptiveStatistics();
	List<Double> ntoldata = collectThresholdNat();
	for (int n = 0; n < ntoldata.size(); n++)
	{
		natTolStats.addValue(ntoldata.get(n));
	}

	DescriptiveStatistics migTolStats = new DescriptiveStatistics();
	List<Double> mtoldata = collectThresholdMig();
	for (int m = 0; m < mtoldata.size(); m++)
	{
		migTolStats.addValue(mtoldata.get(m));
	}
	returnList.add(tolstats);
	returnList.add(natTolStats);
	returnList.add(migTolStats);

	return returnList;
}
 
开发者ID:lursel,项目名称:ABM-adaptive-tolerance,代码行数:30,代码来源:Simulation.java

示例15: medianMisMatch

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
private static int medianMisMatch (String matchLine) {
	DescriptiveStatistics stats = new DescriptiveStatistics();
	for (int i=0; i<matchLine.length(); i++) {
		if  (matchLine.substring(i, i+1).equals(" ")) {
			stats.addValue(i+1);
		}
	}
	double median = 100 * (double) stats.getPercentile(50) / (double) matchLine.length();
	return (int) median;
}
 
开发者ID:hivdb,项目名称:sierra,代码行数:11,代码来源:BlastXmlOutputParser.java


注:本文中的org.apache.commons.math3.stat.descriptive.DescriptiveStatistics.addValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。