當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。