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


Java StatUtils类代码示例

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


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

示例1: getMean

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
/**
 * Get the mean of the data set.
 *
 * @param data the data set.
 * @return the mean of the data set.
 */
private float[] getMean(ArrayDeque<float[]> data) {
    float[] mean = new float[3];

    double[][] values = new double[3][data.size()];
    int index = 0;

    for (float[] axis : data) {
        for (int i = 0; i < axis.length; i++) {
            values[i][index] = axis[i];
        }
        index++;
    }

    for (int i = 0; i < mean.length; i++) {
        mean[i] = (float) StatUtils.percentile(values[i], 50);
    }

    return mean;
}
 
开发者ID:KalebKE,项目名称:FSensor,代码行数:26,代码来源:MedianFilter.java

示例2: filter1

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
private void filter1() {
	// TODO Auto-generated method stub
	List<Integer> rl = new ArrayList<Integer>();
	for(int i=0; i<this.allele.size(); i++) {
		if(this.allele.get(i).length != 2) {
			rl.add(i);
			continue;
		}
		double[] ds = new double[Constants._ploidy_H+1];
		for(int j=0; j<this.gl.get(i).size(); j++) {
			double[] d = this.gl.get(i).get(j);
			for(int k=0; k<d.length; k++)
				ds[k] += d[k];
		}
		if((ds[0]+ds[Constants._ploidy_H])/
				StatUtils.sum(ds)>0.9) 
			rl.add(i);
	}
	this.remove(ArrayUtils.toPrimitive(rl.toArray(new Integer[rl.size()])));
	return;
}
 
开发者ID:c-zhou,项目名称:polyGembler,代码行数:22,代码来源:DataEntry.java

示例3: DP

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
public DP(double[] likelihood, 
		int es,
		int esg,
		boolean isparent, 
		boolean logspace) {
	// TODO Auto-generated constructor stub
	this.isparent = isparent;
	this.allowtrans = !isparent;
	this.emiss = new double[es];
	//this.emissG = new double[es][esg];
	this.hweDist1 = new double[likelihood.length];
	Arrays.fill(hweDist1, 1.0/likelihood.length);
	if(logspace) likelihood = normalspace(likelihood);
	if(StatUtils.max(likelihood)<=0.0) 
		Arrays.fill(likelihood, 1.0);
	likelihood = Algebra.normalize(likelihood);
	for(int i=0; i<likelihood.length; i++)
		likelihood[i] = hweDist1[i]*Constants._soften_ + 
		likelihood[i]*(1-Constants._soften_);
	this.likelihood = likelihood;
	if(logspace) this.setNormalspace();
}
 
开发者ID:c-zhou,项目名称:polyGembler,代码行数:23,代码来源:HiddenMarkovModel.java

示例4: print

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
private void print(double[][] ds) {
	// TODO Auto-generated method stub
	//AnsiConsole.systemInstall();
	
	for(int i=0; i<ds.length; i++) {
		double m = StatUtils.min(ds[i]);
		for(int j=0; j<ds[i].length; j++) { 
			if(ds[i][j]==m) { 
				//System.out.print(ansi().fg(RED).
				//		a(formatter.format(ds[i][j])+"\t").reset());
				System.out.print(formatter.format(ds[i][j])+"\t");
				System.out.flush();
			} else {
				System.out.print(formatter.format(ds[i][j])+"\t");
				System.out.flush();
			}
		}
		System.out.println();
		System.out.flush();
	}
	System.out.println();
	System.out.flush();
	//AnsiConsole.systemUninstall();
}
 
开发者ID:c-zhou,项目名称:polyGembler,代码行数:25,代码来源:RFEstimatorML.java

示例5: min

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
private double[] min(double[][] ds) {
	// TODO Auto-generated method stub
	double tot=Double.POSITIVE_INFINITY, 
			rf=Double.POSITIVE_INFINITY;
	double f;
	int r = -1;
	int n = ds.length;
	for(int i=0; i<n; i++) 
		if( (f=StatUtils.min(ds[i]))<rf ||
				f==rf && StatUtils.sum(ds[i])<tot ) {
			rf = f;
			tot = StatUtils.sum(ds[i]);
			r = i;
		}
	return ds[r];
}
 
开发者ID:c-zhou,项目名称:polyGembler,代码行数:17,代码来源:RFEstimatorML.java

示例6: max

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
private double[] max(double[][] ds) {
	// TODO Auto-generated method stub
	double tot=Double.NEGATIVE_INFINITY, 
			rf=Double.NEGATIVE_INFINITY;
	double f;
	int r = -1;
	int n = ds.length;
	for(int i=0; i<n; i++) 
		if( (f=StatUtils.max(ds[i]))>rf ||
				f==rf && StatUtils.sum(ds[i])>tot ) {
			rf = f;
			tot = StatUtils.sum(ds[i]);
			r = i;
		}
	return ds[r];
}
 
开发者ID:c-zhou,项目名称:polyGembler,代码行数:17,代码来源:RFEstimatorRS2.java

示例7: logDensity

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
public static double logDensity(double[] alpha, double[] x) {
	if(StatUtils.sum(x)!=1) return 0;
	double A = org.apache.commons.math3.special.
			Gamma.logGamma(StatUtils.sum(alpha));
	double B = 0;
	for(int i=0; i<alpha.length; i++) 
		B += org.apache.commons.math3.special.
			Gamma.logGamma(alpha[i]);
	double C = 0;
	for(int i=0; i<x.length; i++)
		C += (alpha[i]-1)*Math.log(x[i]);
	
	System.out.println(A);
	System.out.println(B);
	System.out.println(C);
	return A-B+C;
}
 
开发者ID:c-zhou,项目名称:polyGembler,代码行数:18,代码来源:Dirichlet.java

示例8: execute

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
@Override
public Solutions<V> execute() {
    int nextPercentageReport = 10;
    while ((currentGeneration < maxGenerations) && !stop) {
        step();
        int percentage = Math.round((currentGeneration * 100) / maxGenerations);
        if (percentage == nextPercentageReport) {
            double[][] objs = new double[problem.getNumberOfObjectives()][population.size()];
            String logStr = "";
            for (int i=0; i<objs.length; i++) {
                for (int j=0; j<objs[0].length; j++) {
                    objs[i][j] = population.get(j).getObjective(i);
                }
                logStr += " - Obj. "+i+": Max. "+StatUtils.max(objs[i])+"; Avg. "+StatUtils.mean(objs[i])+"; Min. "+StatUtils.min(objs[i]);
            }
            logger.info(percentage + "% performed ... "+logStr);
            nextPercentageReport += 10;
        }

    }
    return this.getCurrentSolution();       
}
 
开发者ID:hecoding,项目名称:Pac-Man,代码行数:23,代码来源:MultiObjectiveMemeticAlgorithm.java

示例9: generateWeights

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
/**
 * Generates the reference points (weights) for the given number of
 * divisions.
 * 
 * @param point the partially generated point, or {@code null} for the first
 *        invocation
 * @param divisions the number of divisions
 * @return the list of reference points
 */
private List<double[]> generateWeights(double[] point, int divisions) {
	List<double[]> result = new ArrayList<double[]>();
	double sum = 0.0;
	int N = divisions;

	if (point != null) {
		sum = StatUtils.sum(point);
		N = (int)((1.0 - sum)*divisions);
	} else {
		point = new double[0];
	}

	if (point.length < numberOfObjectives-1) {
		for (int i = 0; i <= N; i++) {
			result.addAll(generateWeights(extend(point, i/(double)divisions), divisions));
		}
	} else {
		result.add(extend(point, 1.0 - sum));
	}

	return result;
}
 
开发者ID:Matsemann,项目名称:eamaster,代码行数:32,代码来源:ReferencePointNondominatedSortingPopulation.java

示例10: getOperatorProbabilities

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
/**
 * Returns the array of probabilities of applying each operator.
 * 
 * @return the array of probabilities of applying each operator
 */
protected double[] getOperatorProbabilities() {
	double[] count = new double[operators.size()];
	Arrays.fill(count, 1.0);

	for (Solution solution : archive) {
		if (solution.hasAttribute(OPERATOR_ATTRIBUTE)) {
			count[(Integer)solution.getAttribute(OPERATOR_ATTRIBUTE)]++;
		}
	}

	double sum = StatUtils.sum(count);
	double[] probabilities = new double[count.length];

	for (int i = 0; i < count.length; i++) {
		probabilities[i] = count[i] / sum;
	}

	return probabilities;
}
 
开发者ID:Matsemann,项目名称:eamaster,代码行数:25,代码来源:AdaptiveMultimethodVariation.java

示例11: testSample

import org.apache.commons.math3.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:Quanticol,项目名称:CARMA,代码行数:19,代码来源:SemiVarianceTest.java

示例12: testMinMax

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
@Test
public void testMinMax() {
    da.addElement(2.0);
    da.addElement(22.0);
    da.addElement(-2.0);
    da.addElement(21.0);
    da.addElement(22.0);
    da.addElement(42.0);
    da.addElement(62.0);
    da.addElement(22.0);
    da.addElement(122.0);
    da.addElement(1212.0);

    Assert.assertEquals("Min should be -2.0", -2.0, StatUtils.min(da.getElements()), Double.MIN_VALUE);
    Assert.assertEquals(
        "Max should be 1212.0",
        1212.0,
        StatUtils.max(da.getElements()),
        Double.MIN_VALUE);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:21,代码来源:DoubleArrayAbstractTest.java

示例13: computeStat

import org.apache.commons.math3.stat.StatUtils; //导入依赖的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

示例14: calculateOverallAnnotationSufficiencyForAttributeSet

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
public double calculateOverallAnnotationSufficiencyForAttributeSet(Set<OWLClass> atts) throws UnknownOWLClassException {
	SummaryStatistics stats = computeAttributeSetSimilarityStats(atts);
	if ((this.getSummaryStatistics() == null) || Double.isNaN(this.getSummaryStatistics().mean.getMean())) {
		LOG.info("Stats have not been computed yet - doing this now");
		this.computeSystemStats();
	}
	// score = mean(atts)/mean(overall) + max(atts)/max(overall) + sum(atts)/mean(sum(overall))
	double overall_score = 0.0;
	Double mean_score = stats.getMean();
	Double max_score = stats.getMax();
	Double sum_score = stats.getSum();
	if (!(mean_score.isNaN() || max_score.isNaN() || sum_score.isNaN())) {
		mean_score = StatUtils.min(new double[]{(mean_score / this.overallSummaryStatsPerIndividual.mean.getMean()),1.0});
		max_score = StatUtils.min(new double[]{(max_score / this.overallSummaryStatsPerIndividual.max.getMax()),1.0});
		sum_score = StatUtils.min(new double[]{(sum_score / this.overallSummaryStatsPerIndividual.sum.getMean()),1.0});
		overall_score = (mean_score + max_score + sum_score) / 3;		
	}
	LOG.info("Overall mean: "+mean_score + " max: "+max_score + " sum:"+sum_score + " combined:"+overall_score);
	return overall_score;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:21,代码来源:AbstractOwlSim.java

示例15: verifyINodesPartial

import org.apache.commons.math3.stat.StatUtils; //导入依赖的package包/类
protected int verifyINodesPartial(final List<INode> inodes, final String[]
    names, final int[] parentIds, final int[] inodeIds) throws IOException {
  int index = (int)StatUtils.min(new double[]{inodes.size(), inodeIds
      .length, parentIds.length, names.length});
  for (int i = 0; i < index; i++) {
    INode inode = inodes.get(i);
    boolean noChangeInInodes =
        inode != null && inode.getLocalName().equals(names[i]) &&
            inode.getParentId() == parentIds[i] &&
            inode.getId() == inodeIds[i];
    if (!noChangeInInodes) {
      index = i;
      break;
    }
  }
  return index;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:18,代码来源:INodeLock.java


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