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


Java StandardDeviation类代码示例

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


StandardDeviation类属于org.apache.commons.math3.stat.descriptive.moment包,在下文中一共展示了StandardDeviation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testStdDevOperation

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
@Test
public void testStdDevOperation() throws Exception {
    List<Map<String, Object>> expected = JsonFileUtil.readJsonFromResource("raw.json");
    double[] doubleList = new double[expected.size()];
    int i = 0;
    for (Map<String, Object> o : expected) {
        doubleList[i++] = (double) ((Map) o.get("test")).get("f");
    }
    double stddev = new StandardDeviation().evaluate(doubleList);
    Aggregation aggregation = new AggregationBuilder()
            .addOperation("stddev", new StdDevPopOperation("test.f"))
            .getAggregation();
    List<Map<String, Object>> result = aggregation.aggregate(jsonList);
    assertEquals("Standard Deviation should be as expected",
            stddev,
            result.get(0).get("stddev"));
}
 
开发者ID:caffinc,项目名称:jaggr,代码行数:18,代码来源:AggregationTest.java

示例2: computePopulationStandardDeviationOfBigDecimals

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
public static BigDecimal computePopulationStandardDeviationOfBigDecimals(List<BigDecimal> numbers) {
    
    if ((numbers == null) || numbers.isEmpty()) {
        return null;
    }
    
    try {
        double[] doublesArray = new double[numbers.size()];

        for (int i = 0; i < doublesArray.length; i++) {
            doublesArray[i] = numbers.get(i).doubleValue();
        }

        StandardDeviation standardDeviation = new StandardDeviation();
        standardDeviation.setBiasCorrected(false);
        BigDecimal standardDeviationResult = new BigDecimal(standardDeviation.evaluate(doublesArray));

        return standardDeviationResult;
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));
        return null;
    }
}
 
开发者ID:PearsonEducation,项目名称:StatsAgg,代码行数:25,代码来源:MathUtilities.java

示例3: calculateParamStdDev

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
/**
 * @param numberOfUtterances number of utterances
 * @param fileNumber file number
 * @param audioParams audio parameters
 * @param stdDevParam old standard deviation value of audio parameter
 * @return stdDevParam new standard deviation value of audio parameter
 */
private static double[][] calculateParamStdDev(int numberOfUtterances, int fileNumber, String[][] audioParams, double[][] stdDevParam) {
	
	for	(int cols=0; cols<HEADER_COLUMNS; cols++)	{
		stdDevParam[fileNumber][cols] = 0;
	}
	
	for	(int cols=HEADER_COLUMNS; cols<PARAMS_NUM; cols++)	{
		double[] colValues = new double[numberOfUtterances];	
		for	(int rows =0; rows< numberOfUtterances; rows++)	{
			if	(!audioParams[rows][cols].equals(""))	{
				colValues[rows] = Double.parseDouble(audioParams[rows][cols].replace("%",""));
			}
			else
				colValues[rows] = 0;
		}
		stdDevParam[fileNumber][cols] = new StandardDeviation().evaluate(colValues);
	}
	
	return stdDevParam;
}
 
开发者ID:UKPLab,项目名称:jlcl2015-pythagoras,代码行数:28,代码来源:FindOutliers.java

示例4: computeStat

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
public void computeStat(double duration, int maxUsers) {
    double[] times = getDurationAsArray();
    min = (long) StatUtils.min(times);
    max = (long) StatUtils.max(times);
    double sum = 0;
    for (double d : times) sum += d;
    avg = sum / times.length;
    p50 = (long) StatUtils.percentile(times, 50.0);
    p95 = (long) StatUtils.percentile(times, 95.0);
    p99 = (long) StatUtils.percentile(times, 99.0);
    StandardDeviation stdDev = new StandardDeviation();
    stddev = (long) stdDev.evaluate(times, avg);
    this.duration = duration;
    this.maxUsers = maxUsers;
    rps = (count - errorCount) / duration;
    startDate = getDateFromInstant(start);
    successCount = count - errorCount;
}
 
开发者ID:nuxeo,项目名称:gatling-report,代码行数:19,代码来源:RequestStat.java

示例5: get_cv

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
public Map<String, Double> get_cv(String[] group_var, String[] uniq_group){
    Map<String, Double> group_to_cv_map = new TreeMap<String, Double>();
    Map<String, ArrayList<Double> > grouped_y = new TreeMap<String, ArrayList<Double>>();
    for (String aUniq_group : uniq_group){
        grouped_y.put(aUniq_group, new ArrayList<Double>());
        for (int i = 0; i < group_var.length; i++) {
            if (group_var[i].equals(aUniq_group)){
                grouped_y.get(aUniq_group).add(this.y_list.get(i));
            }
        }
    }

    StandardDeviation std_stat = new StandardDeviation(true);
    Mean mean_stat = new Mean();
    for(Iterator<Map.Entry<String, ArrayList<Double>>> it = grouped_y.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry<String, ArrayList<Double>> entry = it.next();
        double[] cur_y_arr = ArrayUtils.toPrimitive(entry.getValue().toArray(new Double[entry.getValue().size()]));
        double  std = std_stat.evaluate(cur_y_arr);
        double mean = mean_stat.evaluate(cur_y_arr);
        group_to_cv_map.put(entry.getKey(), std/mean);
    }

    this.cv = group_to_cv_map;
    return group_to_cv_map;
}
 
开发者ID:jiach,项目名称:MetaDiff,代码行数:26,代码来源:ArrFPKM.java

示例6: calculateT

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
private static double calculateT(final ReadCountCollection tangentNormalizedCoverage, final List<ModeledSegment> segments) {

        //Get the segments that are likely copy neutral.
        // Math.abs removed to mimic python...
        final List<ModeledSegment> copyNeutralSegments = segments.stream().filter(s -> s.getSegmentMean() < COPY_NEUTRAL_CUTOFF).collect(Collectors.toList());

        // Get the targets that correspond to the copyNeutralSegments... note that individual targets, due to noise,
        //  can be far away from copy neutral
        final TargetCollection<ReadCountRecord.SingleSampleRecord> targetsWithCoverage =
                new HashedListTargetCollection<>(tangentNormalizedCoverage.records().stream().map(ReadCountRecord::asSingleSampleRecord).collect(Collectors.toList()));
        final double[] copyNeutralTargetsCopyRatio = copyNeutralSegments.stream()
                .flatMap(s -> targetsWithCoverage.targets(s).stream())
                .mapToDouble(ReadCountRecord.SingleSampleRecord::getCount).toArray();

        final double meanCopyNeutralTargets = new Mean().evaluate(copyNeutralTargetsCopyRatio);
        final double sigmaCopyNeutralTargets = new StandardDeviation().evaluate(copyNeutralTargetsCopyRatio);

        // Now we filter outliers by only including those w/in 2 standard deviations.
        final double [] filteredCopyNeutralTargetsCopyRatio = Arrays.stream(copyNeutralTargetsCopyRatio)
                .filter(c -> Math.abs(c - meanCopyNeutralTargets) < sigmaCopyNeutralTargets * Z_THRESHOLD).toArray();

        return new StandardDeviation().evaluate(filteredCopyNeutralTargetsCopyRatio);
    }
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:24,代码来源:ReCapSegCaller.java

示例7: testSliceSamplingOfNormalDistribution

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
/**
 * Test slice sampling of a normal distribution.  Checks that input mean and standard deviation are recovered
 * by 10000 samples to a relative error of 0.5% and 2%, respectively.
 */
@Test
public void testSliceSamplingOfNormalDistribution() {
    rng.setSeed(RANDOM_SEED);

    final double mean = 5.;
    final double standardDeviation = 0.75;
    final NormalDistribution normalDistribution = new NormalDistribution(mean, standardDeviation);
    final Function<Double, Double> normalLogPDF = normalDistribution::logDensity;

    final double xInitial = 1.;
    final double xMin = Double.NEGATIVE_INFINITY;
    final double xMax = Double.POSITIVE_INFINITY;
    final double width = 0.5;
    final int numSamples = 10000;
    final SliceSampler normalSampler = new SliceSampler(rng, normalLogPDF, xMin, xMax, width);
    final double[] samples = Doubles.toArray(normalSampler.sample(xInitial, numSamples));

    final double sampleMean = new Mean().evaluate(samples);
    final double sampleStandardDeviation = new StandardDeviation().evaluate(samples);
    Assert.assertEquals(relativeError(sampleMean, mean), 0., 0.005);
    Assert.assertEquals(relativeError(sampleStandardDeviation, standardDeviation), 0., 0.02);
}
 
开发者ID:broadinstitute,项目名称:gatk-protected,代码行数:27,代码来源:SliceSamplerUnitTest.java

示例8: evaluate

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
@Override
/**
 * @return [0] Mean  distance [1] SD  distance 
 */
public double[] evaluate() {
	splinefit = new TrajectorySplineFit(t,nSegments);
	splinefit.calculateSpline();
	if(!splinefit.wasSuccessfull()){
		return new double[] {Double.NaN,Double.NaN};
	}
	double[] data = new double[t.size()];
	for(int i = 0; i < t.size(); i++){
		
		Point2D.Double help = new Point2D.Double(splinefit.getRotatedTrajectory().get(i).x, splinefit.getRotatedTrajectory().get(i).y);
		data[i] = help.distance(splinefit.minDistancePointSpline(new Point2D.Double(splinefit.getRotatedTrajectory().get(i).x, splinefit.getRotatedTrajectory().get(i).y), 50));
	}
	Mean m = new Mean();
	StandardDeviation sd = new StandardDeviation();
	result = new double[] {m.evaluate(data),sd.evaluate(data)};
	return result;

	 
}
 
开发者ID:thorstenwagner,项目名称:TraJ,代码行数:24,代码来源:SplineCurveSpatialFeature.java

示例9: assertLongTermStd

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
/**
  * Assert that the long term mean of values drawn from a {@link RandomSeries} object
  * is as expected.
  * 
  * @param series (<code>S</code>) <br>
  *        The {@link RandomSeries} object to test.
  * @param numberOfSamples <br>
  *        The number of samples to draw from <code>S</code>.
  * @param expectedLongTermStd <br>
  *        The expected long term standard deviation of the series.
  */
protected void assertLongTermStd(
   RandomSeries series,
   final int numberOfSamples,
   final double expectedLongTermStd
   ) {
   final List<Double>
      observations = new ArrayList<Double>();
   
   for(int i = 0; i< numberOfSamples; ++i)
      observations.add(series.next());
   
   final double observedMean = 
      (new StandardDeviation()).evaluate(ArrayUtils.toPrimitive(
         observations.toArray(new Double[observations.size()])));
   
   Assert.assertEquals(observedMean, expectedLongTermStd, 1.e-1);
}
 
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:29,代码来源:TestAbstractSeries.java

示例10: testPinkNoise

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
@Test
public void testPinkNoise() {
    short[] pinkNoise = SOSSignalProcessing.makePinkNoise(441000, (short)2500, 0);
    FFTSignalProcessing fftSignalProcessing = new FFTSignalProcessing(44100,
            ThirdOctaveBandsFiltering.STANDARD_FREQUENCIES_REDUCED, pinkNoise.length);
    fftSignalProcessing.addSample(pinkNoise);
    FFTSignalProcessing.ProcessingResult result = fftSignalProcessing.processSample(false,
            false,
            false);

    // Compute
    StandardDeviation standardDeviation = new StandardDeviation();
    double[] dArray = new double[result.dBaLevels.length];
    for(int i = 0; i < result.dBaLevels.length; i++) {
        dArray[i] = result.dBaLevels[i];
    }
    assertEquals(0, standardDeviation.evaluate(dArray), 0.25);
}
 
开发者ID:Ifsttar,项目名称:NoiseCapture,代码行数:19,代码来源:ThirdOctaveBandsFilteringTest.java

示例11: buildRun

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
private Callable<Result> buildRun(final int kSize, final int numRuns,
                                  final List<String> lines) {
    return new Callable<Result>() {
        public Result call() throws Exception {
            long start = System.currentTimeMillis();
            final double[] results = new double[numRuns];
            for (int i = 0; i < numRuns; i++) {
                Recordinality rec = new Recordinality(kSize);
                for (String line : lines) rec.observe(line);
                results[i] = rec.estimateCardinality();
            }
            double mean = new Mean().evaluate(results);
            double stdDev = new StandardDeviation().evaluate(results);
            double stdError = stdDev / 3193;
            long runTime = System.currentTimeMillis() - start;
            return new Result(kSize, mean, stdError, runTime);
        }
    };
}
 
开发者ID:cscotta,项目名称:recordinality,代码行数:20,代码来源:RecordinalityTest.java

示例12: testInformationNumericFeature

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
@Test
public void testInformationNumericFeature() {
  ExampleSet exampleSet = examplesForFeaturesValues(
      new float[]{0.0f, 1.0f, 2.0f, 4.0f},
      new float[]{1.0f, 1.5f, 2.0f, 5.0f}
  );
  List<Decision> decisions = Decision.decisionsFromExamples(exampleSet, 0, 100);
  assertEquals(3, decisions.size());
  assertEquals(3.0f, ((NumericDecision) decisions.get(0)).getThreshold());
  assertEquals(1.5f, ((NumericDecision) decisions.get(1)).getThreshold());
  assertEquals(0.5f, ((NumericDecision) decisions.get(2)).getThreshold());
  Pair<Decision,Double> best = NumericalInformation.bestGain(decisions, exampleSet);
  assertEquals(1.5f, ((NumericDecision) best.getFirst()).getThreshold());

  StandardDeviation all = new StandardDeviation();
  all.incrementAll(new double[] {1.0,1.5,2.0,5.0});
  StandardDeviation positive = new StandardDeviation();
  positive.incrementAll(new double[] {1.0,1.5});
  StandardDeviation negative = new StandardDeviation();
  negative.incrementAll(new double[] {2.0,5.0});

  assertEquals(differentialEntropy(all)
                   - (2.0/4.0)*differentialEntropy(positive)
                   - (2.0/4.0)*differentialEntropy(negative),
               best.getValue().doubleValue());
}
 
开发者ID:apsaltis,项目名称:oryx,代码行数:27,代码来源:NumericInformationTest.java

示例13: standardDeviation

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
private static double standardDeviation(List<Double> values) {

        double[] array = new double[values.size()];
        for (int i = 0; i < array.length; i++) {
            array[i] = values.get(i);
        }
        return new StandardDeviation().evaluate(array);
    }
 
开发者ID:stacs-srg,项目名称:ciesvium,代码行数:9,代码来源:ConfidenceIntervals.java

示例14: Endpoint

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
protected Endpoint(String path, double relativeProb) {
  Preconditions.checkArgument(relativeProb > 0.0);
  this.path = path;
  this.relativeProb = relativeProb;
  meanTimeNanos = new Mean();
  stdevTimeNanos = new StandardDeviation();
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:8,代码来源:Endpoint.java

示例15: stdDev

import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; //导入依赖的package包/类
private static double stdDev(List<Long> data) {
  double[] asDouble = new double[data.size()];
  int i = 0;
  for (Long l : data) {
    asDouble[i++] = (double) l;
  }
  return new StandardDeviation().evaluate(asDouble);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:9,代码来源:TestMfsBlockLoader.java


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