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


Java StatUtils.mean方法代码示例

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


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

示例1: testSample

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
public void testSample() {
    final double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    final int length = values.length;
    final double mean = StatUtils.mean(values); // 6.333...
    final SemiVariance sv = new SemiVariance();  // Default bias correction is true
    final double downsideSemiVariance = sv.evaluate(values); // Downside is the default
    assertEquals(TestUtils.sumSquareDev(new double[] {-2d, 2d, 4d, -2d, 3d, 5d}, mean) / (length - 1),
            downsideSemiVariance, 1E-14);

    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upsideSemiVariance = sv.evaluate(values);
    assertEquals(TestUtils.sumSquareDev(new double[] {22d, 11d, 14d}, mean) / (length - 1),
            upsideSemiVariance, 1E-14);

    // Verify that upper + lower semivariance against the mean sum to variance
    assertEquals(StatUtils.variance(values), downsideSemiVariance + upsideSemiVariance, 10e-12);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:SemiVarianceTest.java

示例2: testSample

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
@Test
public void testSample() {
    final double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    final int length = values.length;
    final double mean = StatUtils.mean(values); // 6.333...
    final SemiVariance sv = new SemiVariance();  // Default bias correction is true
    final double downsideSemiVariance = sv.evaluate(values); // Downside is the default
    Assert.assertEquals(TestUtils.sumSquareDev(new double[] {-2d, 2d, 4d, -2d, 3d, 5d}, mean) / (length - 1),
            downsideSemiVariance, 1E-14);

    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upsideSemiVariance = sv.evaluate(values);
    Assert.assertEquals(TestUtils.sumSquareDev(new double[] {22d, 11d, 14d}, mean) / (length - 1),
            upsideSemiVariance, 1E-14);

    // Verify that upper + lower semivariance against the mean sum to variance
    Assert.assertEquals(StatUtils.variance(values), downsideSemiVariance + upsideSemiVariance, 10e-12);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:SemiVarianceTest.java

示例3: testSample

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
public void testSample() {
    final double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    final int length = values.length;
    final double mean = StatUtils.mean(values); // 6.333...
    final SemiVariance sv = new SemiVariance();  // Default bias correction is true
    final double downsideSemiVariance = sv.evaluate(values); // Downside is the default
    assertEquals(TestUtils.sumSquareDev(new double[] {-2d, 2d, 4d, -2d, 3d, 5d}, mean) / (length - 1),
            downsideSemiVariance, 1E-14);

    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upsideSemiVariance = sv.evaluate(values);
    assertEquals(TestUtils.sumSquareDev(new double[] {22d, 11d, 14d}, mean) / (length - 1),
            upsideSemiVariance, 1E-14);
    
    // Verify that upper + lower semivariance against the mean sum to variance
    assertEquals(StatUtils.variance(values), downsideSemiVariance + upsideSemiVariance, 10e-12);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:SemiVarianceTest.java

示例4: createLeaf

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
@Override
protected <T extends ITrainingPoint<R, N>> DTNode<R, Double> createLeaf(Collection<T> set)
{

	double[] values = new double[set.size()];
	int i = 0;
	for (T point : set)
	{
		values[i] = point.getContent().doubleValue();
		i++;
	}
	double mean = StatUtils.mean(values);
	
	// Create the leaf
	DTNode<R, Double> leaf = new DTNode<R, Double>();
	leaf.setContent(mean);
	
	return leaf;
}
 
开发者ID:williamleif,项目名称:PSRToolbox,代码行数:20,代码来源:RegressionERTGrower.java

示例5: process

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
@Override
public void process(DoubleTimeSeries series) {
	final long[] times = series.getTimes();
	final double[] data = series.getData();
	final int size = series.size();
	for (int i = size - 1; i >= 0; i--) {
		final long latest = times[i];
		final long earliest = latest - length;
		final DoubleTimeSeries spanoftime = series.get(earliest, latest);
		data[i] = StatUtils.mean(spanoftime.getData());
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:13,代码来源:MovingAverageProcessor.java

示例6: getMean

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
/**
 *
 * @param list
 * @return
 */
public double getMean(List<SynsetOut> list) {
    double[] scores = new double[list.size()];
    int l = 0;
    for (SynsetOut out : list) {
        scores[l] = out.getScore();
        l++;
    }
    return StatUtils.mean(scores);
}
 
开发者ID:pippokill,项目名称:lesk-wsd-dsm,代码行数:15,代码来源:RevisedLesk.java

示例7: evaluate

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
@Override
public Double evaluate(ArrayList<C> leafsContent)
{
	double[] evaluations = new double[leafsContent.size()];
	for (int i = 0; i < evaluations.length; i++)
	{
		double value = leafsContent.get(i).doubleValue();
		evaluations[i] = value;
	}
	double mean = StatUtils.mean(evaluations);
	return mean;
}
 
开发者ID:williamleif,项目名称:PSRToolbox,代码行数:13,代码来源:ForestRegressionEvaluator.java

示例8: compute

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
public static PairedEndStats compute(Iterator<Alignment> alignments, double minPercentile, double maxPercentile) {


        double[] insertSizes = new double[MAX_PAIRS];
        int nPairs = 0;

        while (alignments.hasNext()) {


            Alignment al = alignments.next();

            if (isProperPair(al)) {
                insertSizes[nPairs] = Math.abs(al.getInferredInsertSize());
                nPairs++;
            }


            if (nPairs >= MAX_PAIRS) {
                break;
            }

        }

        if(nPairs == 0) {
            log.error("Error computing insert size distribution. No alignments in sample interval.");
            return null;
        }

        double mean = StatUtils.mean(insertSizes, 0, nPairs);
        double median = StatUtils.percentile(insertSizes, 0, nPairs, 50);
        double stdDev = Math.sqrt(StatUtils.variance(insertSizes, 0, nPairs));

        double[] deviations = new double[nPairs];
        for (int i = 0; i < nPairs; i++) {
            deviations[i] = Math.abs(insertSizes[i] - median);
        }

        // MAD, as defined at http://stat.ethz.ch/R-manual/R-devel/library/stats/html/mad.html
        double mad = 1.4826 * StatUtils.percentile(deviations, 50);

        double sec = StatUtils.percentile(insertSizes, 0, nPairs, minPercentile);
        double max = StatUtils.percentile(insertSizes, 0, nPairs, maxPercentile);

        PairedEndStats stats = new PairedEndStats(mean, median, stdDev, mad, sec, max);

        return stats;
    }
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:48,代码来源:PairedEndStats.java


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