當前位置: 首頁>>代碼示例>>Java>>正文


Java StatUtils.sum方法代碼示例

本文整理匯總了Java中org.apache.commons.math3.stat.StatUtils.sum方法的典型用法代碼示例。如果您正苦於以下問題:Java StatUtils.sum方法的具體用法?Java StatUtils.sum怎麽用?Java StatUtils.sum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.math3.stat.StatUtils的用法示例。


在下文中一共展示了StatUtils.sum方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: distortion

import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
private double distortion(double[] ds) {
	// TODO Auto-generated method stub
	double[] dt = new double[this.configuration.length];
	long[] dsL = new long[ds.length];
	double s = StatUtils.sum(ds);
	for(int i=0; i<dsL.length; i++)
		dsL[i] = Math.round(ds[i]);
	for(int i=0; i<dt.length; i++) {
		//for(int j=0; j<ds.length; j++)
		//	dt[i] += Math.pow(
		//			ds[j]-this.configuration[i][j], 
		//			2);
		double[] conf = this.configuration[i];
		List<Long> ds_i = new ArrayList<Long>();
		List<Double> conf_i = new ArrayList<Double>();
		boolean b = false;
		for(int j=0; j<conf.length; j++) 
			if(conf[j]!=0) {
				ds_i.add(dsL[j]);
				conf_i.add(conf[j]);		
			} else if (ds[j]/s>0.3) {
				//System.out.println(ds[j]/s);
				b = true;
				break;
			}
		if(b) continue;
		dt[i] = new ChiSquareTest().chiSquareTest(
				ArrayUtils.toPrimitive(conf_i.
						toArray(new Double[conf_i.size()])), 
				ArrayUtils.toPrimitive(ds_i.
						toArray(new Long[ds_i.size()])));
	}
	return Math.sqrt(StatUtils.max(dt));
}
 
開發者ID:c-zhou,項目名稱:polyGembler,代碼行數:35,代碼來源:DataEntry.java

示例8: alpha

import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
private void alpha(final int i, 
		final int z, 
		final double[] c) {
	// TODO Auto-generated method stub
	for(int j=0; j<c.length; j++)
		c[j] += Constants._pseudo_[0]/z;
	double s = StatUtils.sum(c);
	for(int j=0; j<alpha[i].length; j++)
		alpha[i][j] = c[j]/s;
}
 
開發者ID:c-zhou,項目名稱:polyGembler,代碼行數:11,代碼來源:HiddenMarkovModel.java

示例9: getCounts

import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
public void getCounts(double[] hittingProb) {
	int _i_ = count.length;
	double sum = 0;
	for(int i=1; i<_i_; i++) {
		hittingProb[i] = StatUtils.sum(count[i]);
		sum += hittingProb[i];
	}
	if(sum==0) 
		for(int i=1; i<_i_; i++) 
			hittingProb[i] = 1.0/(_i_-1);
	else
		for(int i=1; i<_i_; i++) 
			hittingProb[i] /= sum;
}
 
開發者ID:c-zhou,項目名稱:polyGembler,代碼行數:15,代碼來源:HiddenMarkovModel.java

示例10: posterior

import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
protected void posterior() {
	// TODO Auto-generated method stub
	int _i_ = count.length,
			_j_ = count[0].length;
	for(int i=1; i<_i_; i++) {
		double s = StatUtils.sum(count[i]);
		if(s==0)
			for(int j=0; j<_j_; j++)
				probsMat[i][j] = 1.0/count[i].length;
		else
			for(int j=0; j<_j_; j++)
				probsMat[i][j] = count[i][j]/s;
	}
}
 
開發者ID:c-zhou,項目名稱:polyGembler,代碼行數:15,代碼來源:HiddenMarkovModel.java

示例11: 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;
	for(int i=0; i<ds.length; 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,代碼行數:16,代碼來源:RFEstimatorML.java

示例12: normalize

import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
public static double[] normalize(double[] array) {
	// TODO Auto-generated method stub
	double s = StatUtils.sum(array);
	if(s==0) return array;
	for(int i=0; i<array.length; i++) array[i]/=s;
	return array;
}
 
開發者ID:c-zhou,項目名稱:polyGembler,代碼行數:8,代碼來源:Algebra.java

示例13: normalizedLog

import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
public static double[] normalizedLog(double[] array) {
	// TODO Auto-generated method stub
	double s = StatUtils.sum(array);
	for(int i=0; i<array.length; i++) 
		array[i] = Math.log(array[i]/s);
	return array;
}
 
開發者ID:c-zhou,項目名稱:polyGembler,代碼行數:8,代碼來源:Algebra.java

示例14: computeFirstOrderConfidence

import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
/**
 * Returns the first-order confidence interval of the i-th parameter.  The
 * arguments to this method mirror the arguments to
 * {@link #computeFirstOrder}.
 * 
 * @param a0 the output from the first independent samples
 * @param a1 the output from the samples produced by swapping the i-th
 *        parameter in the first independent samples with the i-th parameter
 *        from the second independent samples
 * @param a2 the output from the second independent samples
 * @param nsample the number of samples
 * @param nresample the number of resamples used when calculating the
 *        confidence interval
 * @return the first-order confidence interval of the i-th parameter
 */
private static double computeFirstOrderConfidence(double[] a0, double[] a1,
		double[] a2, int nsample, int nresample) {
	double[] b0 = new double[nsample];
	double[] b1 = new double[nsample];
	double[] b2 = new double[nsample];
	double[] s = new double[nresample];

	for (int i = 0; i < nresample; i++) {
		for (int j = 0; j < nsample; j++) {
			int index = PRNG.nextInt(nsample);

			b0[j] = a0[index];
			b1[j] = a1[index];
			b2[j] = a2[index];
		}

		s[i] = computeFirstOrder(b0, b1, b2, nsample);
	}

	double ss = StatUtils.sum(s) / nresample;
	double sss = 0.0;
	
	for (int i = 0; i < nresample; i++) {
		sss += Math.pow(s[i] - ss, 2.0);
	}

	return 1.96 * Math.sqrt(sss / (nresample - 1));
}
 
開發者ID:Matsemann,項目名稱:eamaster,代碼行數:44,代碼來源:SobolAnalysis.java

示例15: computeTotalOrderConfidence

import org.apache.commons.math3.stat.StatUtils; //導入方法依賴的package包/類
/**
 * Returns the total-order confidence interval of the i-th parameter.  The
 * arguments to this method mirror the arguments to
 * {@link #computeTotalOrder}.
 * 
 * @param a0 the output from the first independent samples
 * @param a1 the output from the samples produced by swapping the i-th
 *        parameter in the first independent samples with the i-th parameter
 *        from the second independent samples
 * @param a2 the output from the second independent samples
 * @param nsample the number of samples
 * @param nresample the number of resamples used when calculating the
 *        confidence interval
 * @return the total-order confidence interval of the i-th parameter
 */
private static double computeTotalOrderConfidence(double[] a0, double[] a1,
		double[] a2, int nsample, int nresample) {
	double[] b0 = new double[nsample];
	double[] b1 = new double[nsample];
	double[] b2 = new double[nsample];
	double[] s = new double[nresample];

	for (int i = 0; i < nresample; i++) {
		for (int j = 0; j < nsample; j++) {
			int index = PRNG.nextInt(nsample);

			b0[j] = a0[index];
			b1[j] = a1[index];
			b2[j] = a2[index];
		}

		s[i] = computeTotalOrder(b0, b1, b2, nsample);
	}

	double ss = StatUtils.sum(s) / nresample;
	double sss = 0.0;
	
	for (int i = 0; i < nresample; i++) {
		sss += Math.pow(s[i] - ss, 2.0);
	}

	return 1.96 * Math.sqrt(sss / (nresample - 1));
}
 
開發者ID:Matsemann,項目名稱:eamaster,代碼行數:44,代碼來源:SobolAnalysis.java


注:本文中的org.apache.commons.math3.stat.StatUtils.sum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。