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


Java DoubleArrayList.size方法代码示例

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


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

示例1: covariance

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns the covariance of two data sequences, which is 
 * <tt>cov(x,y) = (1/(size()-1)) * Sum((x[i]-mean(x)) * (y[i]-mean(y)))</tt>.
 * See the <A HREF="http://www.cquest.utoronto.ca/geog/ggr270y/notes/not05efg.html"> math definition</A>.
 */
public static double covariance(DoubleArrayList data1, DoubleArrayList data2) {
	int size = data1.size();
	if (size != data2.size() || size == 0) throw new IllegalArgumentException();
	double[] elements1 = data1.elements();
	double[] elements2 = data2.elements();
	
	double sumx=elements1[0], sumy=elements2[0], Sxy=0;
	for (int i=1; i<size; ++i) {
		double x = elements1[i];
		double y = elements2[i];
		sumx += x;
		Sxy += (x - sumx/(i+1))*(y - sumy/i);
		sumy += y;
		// Exercise for the reader: Why does this give us the right answer?
	}
	return Sxy/(size-1);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:23,代码来源:Descriptive.java

示例2: durbinWatson

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Durbin-Watson computation.
 */
public static double durbinWatson(DoubleArrayList data) {
	int size = data.size();
	if (size < 2) throw new IllegalArgumentException("data sequence must contain at least two values.");

	double[] elements = data.elements();
	double run = 0;
	double run_sq = 0;
	run_sq = elements[0] * elements[0];
	for(int i=1; i<size; ++i) {
		double x = elements[i] - elements[i-1];
		run += x*x;
		run_sq += elements[i] * elements[i];
	}

	return run / run_sq;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:20,代码来源:Descriptive.java

示例3: toString

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns a string representation of the receiver, containing
 * the String representation of each key-value pair, sorted ascending by key.
 */
public String toString() {
	DoubleArrayList theKeys = keys();
	theKeys.sort();

	StringBuffer buf = new StringBuffer();
	buf.append("[");
	int maxIndex = theKeys.size() - 1;
	for (int i = 0; i <= maxIndex; i++) {
		double key = theKeys.get(i);
	    buf.append(String.valueOf(key));
		buf.append("->");
	    buf.append(String.valueOf(get(key)));
		if (i < maxIndex) buf.append(", ");
	}
	buf.append("]");
	return buf.toString();
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:22,代码来源:AbstractDoubleIntMap.java

示例4: quantile

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns the <tt>phi-</tt>quantile; that is, an element <tt>elem</tt> for which holds that <tt>phi</tt> percent of data elements are less than <tt>elem</tt>.
 * The quantile need not necessarily be contained in the data sequence, it can be a linear interpolation.
 * @param sortedData the data sequence; <b>must be sorted ascending</b>.
 * @param phi the percentage; must satisfy <tt>0 &lt;= phi &lt;= 1</tt>.
 */
public static double quantile(DoubleArrayList sortedData, double phi) {
	double[] sortedElements = sortedData.elements();
	int n = sortedData.size();
	
	double index = phi * (n - 1) ;
	int lhs = (int)index ;
	double delta = index - lhs ;
	double result;

	if (n == 0) return 0.0 ;

	if (lhs == n - 1) {
		result = sortedElements[lhs] ;
	}
	else {
		result = (1 - delta) * sortedElements[lhs] + delta * sortedElements[lhs + 1] ;
	}

	return result ;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:27,代码来源:Descriptive.java

示例5: weightedMean

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns the weighted mean of a data sequence.
 * That is <tt> Sum (data[i] * weights[i]) / Sum ( weights[i] )</tt>.
 */
public static double weightedMean(DoubleArrayList data, DoubleArrayList weights) {
	int size = data.size();
	if (size != weights.size() || size == 0) throw new IllegalArgumentException();
	
	double[] elements = data.elements();
	double[] theWeights = weights.elements();
	double sum = 0.0;
	double weightsSum = 0.0;
	for (int i=size; --i >= 0; ) {
		double w = theWeights[i];
		sum += elements[i] * w;
		weightsSum += w;
	}

	return sum/weightsSum;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:21,代码来源:Descriptive.java

示例6: toStringByValue

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns a string representation of the receiver, containing
 * the String representation of each key-value pair, sorted ascending by value.
 */
public String toStringByValue() {
	DoubleArrayList theKeys = new DoubleArrayList();
	keysSortedByValue(theKeys);

	StringBuffer buf = new StringBuffer();
	buf.append("[");
	int maxIndex = theKeys.size() - 1;
	for (int i = 0; i <= maxIndex; i++) {
		double key = theKeys.get(i);
	    buf.append(String.valueOf(key));
		buf.append("->");
	    buf.append(String.valueOf(get(key)));
		if (i < maxIndex) buf.append(", ");
	}
	buf.append("]");
	return buf.toString();
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:22,代码来源:AbstractDoubleIntMap.java

示例7: getSqrSum

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
public static double getSqrSum(DoubleArrayList valueList)
{
	double sum =0, tmp ;
	for (int i = 0; i < valueList.size(); i++)
	{
		tmp = valueList.get(i);
		sum += tmp * tmp;
	}
	
	return sum;
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:12,代码来源:Matrix2DUtil.java

示例8: load_metapath

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
double[] load_metapath(MetaPath metaPath)
{
	mat = null;
	try {
		String suffix = "/" + (metaPath.path.size()-1) + "/" + metaPath.toString() + ".mat";
		mat = (List<DoubleMatrix1D>) ObjectWriter.readObject(MatDir + suffix);
		if (mat == null)
		{
			System.err.println("err metapath:" + metaPath);
			return null;
		}
	} catch (Exception e) {
		e.printStackTrace();
	}

	IntArrayList indexArrayList = new IntArrayList();
	DoubleArrayList valueArrayList = new DoubleArrayList();
	if (doc_num == 0 && mat.size() > 0)
		doc_num = mat.size();
	double[] hasInstance = new double[doc_num];
	if (mat.size() > 0)
	{
		for (int i = 0; i < doc_num ; i++)
		{
			mat.get(i).getNonZeros(indexArrayList, valueArrayList);
			for (int j = 0; j < valueArrayList.size(); j++)
				if (valueArrayList.get(j) > 0.0001 &&  i != j)
				{
					hasInstance[i] = 1;
					break;
				}
		}
		return hasInstance;	
	} else {
		System.err.println("err metapath:" + metaPath);
		return null;
	}
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:40,代码来源:calcMI.java

示例9: toString

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns a String representation of the receiver.
 */
public synchronized String toString() {
	StringBuffer buf = new StringBuffer(super.toString());
	DoubleArrayList distinctElements = new DoubleArrayList();
	IntArrayList frequencies = new IntArrayList();
	frequencies(distinctElements,frequencies);
	if (distinctElements.size() < 100) { // don't cause unintended floods
		buf.append("Distinct elements: "+distinctElements+"\n");
		buf.append("Frequencies: "+frequencies+"\n");
	}
	else {
		buf.append("Distinct elements & frequencies not printed (too many).");
	}
	return buf.toString();
}
 
开发者ID:ContentWise,项目名称:aida,代码行数:18,代码来源:DynamicBin1D.java

示例10: Divides

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
Divides (rebins) a copy of the receiver at the given <i>interval boundaries</i> into bins and returns these bins, such that each bin <i>approximately</i> reflects the data elements of its range.

For each interval boundary of the axis (including -infinity and +infinity), computes the percentage (quantile inverse) of elements less than the boundary.
Then lets {@link #splitApproximately(DoubleArrayList,int)} do the real work.

@param axis an axis defining interval boundaries.
@param resolution a measure of accuracy; the desired number of subintervals per interval. 
*/
public synchronized MightyStaticBin1D[] splitApproximately(hep.aida.IAxis axis, int k) {
	DoubleArrayList percentages = new DoubleArrayList(new hep.aida.ref.Converter().edges(axis));
	percentages.beforeInsert(0,Double.NEGATIVE_INFINITY);
	percentages.add(Double.POSITIVE_INFINITY);
	for (int i=percentages.size(); --i >= 0; ) {
		percentages.set(i, quantileInverse(percentages.get(i)));
	}
	
	return splitApproximately(percentages,k); 
}
 
开发者ID:ContentWise,项目名称:aida,代码行数:20,代码来源:QuantileBin1D.java

示例11: get_fdr

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
public static Map<String, Double> get_fdr(String[] isoform_names, double[] p_val) throws UnequalLengthException {

        if (isoform_names.length!=p_val.length){
            throw new UnequalLengthException("isoform_names: "+Integer.toString(isoform_names.length)+"\tp_val: "+Integer.toString(p_val.length));
        }
        DoubleArrayList arr_fdr = MultipleTestCorrection.benjaminiHochberg(new DoubleArrayList(p_val));
        Map<String, Double> isoform_fdr = new HashMap<String, Double>();
        for (int i = 0; i < arr_fdr.size(); i++) {
            isoform_fdr.put(isoform_names[i], arr_fdr.getQuick(i));
        }
        return isoform_fdr;
    }
 
开发者ID:jiach,项目名称:MetaDiff,代码行数:13,代码来源:FDR.java

示例12: get_fdr

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
public double[] get_fdr(double [] pval){
    DoubleArrayList fdr = MultipleTestCorrection.benjaminiHochberg(new DoubleArrayList(pval));
    double[] fdr_arr = new double[fdr.size()];

    for (int i = 0; i < fdr.size(); i++) {
        fdr_arr[i] = fdr.getQuick(i);
    }
    return fdr_arr;
}
 
开发者ID:jiach,项目名称:MetaDiff,代码行数:10,代码来源:PostProcessor.java

示例13: performExperiment

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Performs one experiment
 * @param algorithm
 * @param benchmarkMeasure
 * @param dataset
 * @param measure
 * @param criterion
 * @param suppressionLimit
 * @throws IOException
 */
private static void performExperiment(BenchmarkDataset dataset,
                                      BenchmarkQualityMeasure measure,
                                      BenchmarkPrivacyModel criterion,
                                      double suppressionLimit) throws IOException {
    
    System.out.println("Performing experiment 3 - " + dataset + "/" + measure + "/" +criterion + "/" + suppressionLimit);
    
    // Perform
    BenchmarkResults run = BenchmarkEnvironment.getBenchmarkResults(BenchmarkAlgorithm.LIGHTNING, dataset, measure, criterion, 600 * 1000, suppressionLimit);
    DoubleArrayList trackRecord = run.trackRecord;
    
    // Check if completed
    boolean complete = run.executionTime < 600 * 1000;
    
    // Min and max
    double min = trackRecord.get(1);
    double max = trackRecord.get(trackRecord.size()-1);

    // For each step
    double previous = Double.MAX_VALUE;
    for (int i = 0; i < trackRecord.size(); i += 2) {
        
        // Normalize
        double utility = min == max ? 1d : (trackRecord.get(i + 1) - min) / (max - min);
        
        // Ignore steps in which utility did not change
        if (utility == -0d) utility = +0d;
        if (utility != previous) {
            previous = utility; 
            BENCHMARK.addRun(measure.toString(), criterion.toString(), String.valueOf(suppressionLimit), dataset.toString());
            BENCHMARK.addValue(TIME, trackRecord.get(i));
            BENCHMARK.addValue(QUALITY, utility);
            BENCHMARK.addValue(COMPLETE, complete);
        }
    }
}
 
开发者ID:arx-deidentifier,项目名称:highdimensional-benchmark,代码行数:47,代码来源:BenchmarkExperiment3.java

示例14: preProcessPhis

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 */
protected DoubleArrayList preProcessPhis(DoubleArrayList phis) {
	if (beta>1.0) {
		phis = phis.copy();
		for (int i=phis.size(); --i >=0;) {
			phis.set(i, (2*phis.get(i) + beta - 1) / (2*beta));
		}		
	}
	return phis;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:12,代码来源:KnownDoubleQuantileEstimator.java

示例15: binaryMultiSearch

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Finds the first and last indexes of a specific element within a sorted list.
 * @return int[]
 * @param list cern.colt.list.DoubleArrayList
 * @param element the element to search for
 */
protected static IntArrayList binaryMultiSearch(DoubleArrayList list, double element) {
	int index = list.binarySearch(element);
	if (index<0) return null; //not found

	int from = index-1;
	while (from>=0 && list.get(from)==element) from--;
	from++;
	
	int to = index+1;
	while (to<list.size() && list.get(to)==element) to++;
	to--;
	
	return new IntArrayList(new int[] {from,to});
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:21,代码来源:QuantileFinderTest.java


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