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


Java DoubleArrayList.elements方法代码示例

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


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

示例1: getNonZeros

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
public void getNonZeros(IntArrayList indexList, DoubleArrayList valueList) {
		boolean fillIndexList = indexList != null;
		boolean fillValueList = valueList != null;
		if (fillIndexList) 
			indexList.clear(); 
		else {
			System.out.println("Wrong use");
			return;
		}
		if (fillValueList) 
			valueList.clear();
		else {
			System.out.println("Wrong use");
			return;
		}
		int[] index = elements.keys().elements();
		double[] value = elements.values().elements(); 
		indexList.elements(index);
		valueList.elements(value);
//		for (int i = 0; i < index.size(); ++i) {
//			indexList.add(index.get(i));
//			valueList.add(value.get(i));
//		}
		
//		int s = size;
//		for (int i=0; i < s; i++) {
//			double value = getQuick(i);
//			if (value != 0) {
//				if (fillIndexList) indexList.add(i);
//				if (fillValueList) valueList.add(value);
//			}
//		}
	}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:34,代码来源:ColtSparseVector.java

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

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

示例4: lag1

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns the lag-1 autocorrelation of a dataset; 
 * Note that this method has semantics different from <tt>autoCorrelation(..., 1)</tt>;
 */
public static double lag1(DoubleArrayList data, double mean) {
	int size = data.size();
	double[] elements = data.elements();
	double r1 ;
	double q = 0 ;
	double v = (elements[0] - mean) * (elements[0] - mean) ;

	for (int i = 1; i < size ; i++) {
		double delta0 = (elements[i-1] - mean);
		double delta1 = (elements[i] - mean);
		q += (delta0 * delta1 - q)/(i + 1);
		v += (delta1 * delta1 - v)/(i + 1);
	}

	r1 = q / v ;
	return r1;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:22,代码来源:Descriptive.java

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

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

示例7: winsorizedMean

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns the winsorized mean of a sorted data sequence.
 *
 * @param sortedData the data sequence; <b>must be sorted ascending</b>.
 * @param mean the mean of the (full) sorted data sequence.
 * @left the number of leading elements to trim.
 * @right the number of trailing elements to trim.
 */
public static double winsorizedMean(DoubleArrayList sortedData, double mean, int left, int right) {
	int N = sortedData.size();
	if (N==0) throw new IllegalArgumentException("Empty data.");
	if (left+right >= N) throw new IllegalArgumentException("Not enough data.");

	double[] sortedElements = sortedData.elements();

	double leftElement = sortedElements[left];
	for(int i=0; i<left; ++i)
		mean += (leftElement-sortedElements[i])/N;

	double rightElement = sortedElements[N-1-right];
	for(int i=0; i<right; ++i)
		mean += (rightElement-sortedElements[N-1-i])/N;

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

示例8: autoCorrelation

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns the auto-correlation of a data sequence.
 */
public static double autoCorrelation(DoubleArrayList data, int lag, double mean, double variance) {
	int N = data.size();
	if (lag >= N) throw new IllegalArgumentException("Lag is too large");

	double[] elements = data.elements();
	double run = 0;
	for( int i=lag; i<N; ++i)
		run += (elements[i]-mean)*(elements[i-lag]-mean);
  
	return (run/(N-lag)) / variance;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:15,代码来源:Descriptive.java

示例9: meanDeviation

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns the mean deviation of a dataset.
 * That is <tt>Sum (Math.abs(data[i]-mean)) / data.size())</tt>.
 */
public static double meanDeviation(DoubleArrayList data, double mean) {
	double[] elements = data.elements();
	int size = data.size();
	double sum=0;
	for (int i=size; --i >= 0;) sum += Math.abs(elements[i]-mean);
	return sum/size;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:12,代码来源:Descriptive.java

示例10: sampleVariance

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns the sample variance of a data sequence.
 * That is <tt>Sum ( (data[i]-mean)^2 ) / (data.size()-1)</tt>.
 */
public static double sampleVariance(DoubleArrayList data, double mean) {
	double[] elements = data.elements();
	int size = data.size();	
	double sum = 0 ;
	// find the sum of the squares 
	for (int i = size; --i >= 0; ) {
		double delta = elements[i] - mean;
		sum += delta * delta;
	}

	return sum / (size-1);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:17,代码来源:Descriptive.java

示例11: sumOfLogarithms

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns the sum of logarithms of a data sequence, which is <tt>Sum( Log(data[i])</tt>.
 * @param data the data sequence.
 * @param from the index of the first data element (inclusive).
 * @param to the index of the last data element (inclusive).
 */
public static double sumOfLogarithms(DoubleArrayList data, int from, int to) {
	double[] elements = data.elements();
	double logsum = 0;
	for (int i=from-1; ++i <= to;) logsum += Math.log(elements[i]);
	return logsum;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:13,代码来源:Descriptive.java

示例12: trimmedMean

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns the trimmed mean of a sorted data sequence.
 *
 * @param sortedData the data sequence; <b>must be sorted ascending</b>.
 * @param mean the mean of the (full) sorted data sequence.
 * @left the number of leading elements to trim.
 * @right the number of trailing elements to trim.
 */
public static double trimmedMean(DoubleArrayList sortedData, double mean, int left, int right) {
	int N = sortedData.size();
	if (N==0) throw new IllegalArgumentException("Empty data.");
	if (left+right >= N) throw new IllegalArgumentException("Not enough data.");

	double[] sortedElements = sortedData.elements();
	int N0=N;
	for(int i=0; i<left; ++i)
		mean += (mean-sortedElements[i])/(--N);
	for(int i=0; i<right; ++i)
		mean += (mean-sortedElements[N0-1-i])/(--N);
	return mean;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:22,代码来源:Descriptive.java

示例13: values

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Fills all values contained in the receiver into the specified list.
 * Fills the list, starting at index 0.
 * After this call returns the specified list has a new size that equals <tt>this.size()</tt>.
 * Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
 * <p>
 * This method can be used to iterate over the values of the receiver.
 *
 * @param list the list to be filled, can have any size.
 */
public void values(DoubleArrayList list) {
	list.setSize(distinct);
	double[] elements = list.elements();
	
	double[] val = values;
	byte[] stat = state;
	
	int j=0;
	for (int i = stat.length ; i-- > 0 ;) {
		if (stat[i]==FULL) elements[j++]=val[i];
	}
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:23,代码来源:OpenIntDoubleHashMap.java

示例14: keys

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Fills all keys contained in the receiver into the specified list.
 * Fills the list, starting at index 0.
 * After this call returns the specified list has a new size that equals <tt>this.size()</tt>.
 * Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(DoubleProcedure)}.
 * <p>
 * This method can be used to iterate over the keys of the receiver.
 *
 * @param list the list to be filled, can have any size.
 */
public void keys(DoubleArrayList list) {
	list.setSize(distinct);
	double[] elements = list.elements();
	
	double[] tab = table;
	byte[] stat = state;
	
	int j=0;
	for (int i = tab.length ; i-- > 0 ;) {
		if (stat[i]==FULL) elements[j++]=tab[i];
	}
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:23,代码来源:OpenDoubleIntHashMap.java

示例15: addAllOfFromTo

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Adds the part of the specified list between indexes <tt>from</tt> (inclusive) and <tt>to</tt> (inclusive) to the receiver.
 *
 * @param values the list of which elements shall be added.
 * @param from the index of the first element to be added (inclusive).
 * @param to the index of the last element to be added (inclusive).
 */
public void addAllOfFromTo(DoubleArrayList values, int from, int to) {
	/*
	// the obvious version, but we can do quicker...
	double[] theValues = values.elements();
	int theSize=values.size();
	for (int i=0; i<theSize; ) add(theValues[i++]);
	*/
	
	double[] valuesToAdd = values.elements();
	int k = this.bufferSet.k();
	int bufferSize = k;
	double[] bufferValues = null;
	if (currentBufferToFill != null) {
		bufferValues = currentBufferToFill.values.elements();
		bufferSize = currentBufferToFill.size();
	}

	for (int i=from-1; ++i <= to; ) {
		if (sampleNextElement()) {
			if (bufferSize == k) { // full
				if (bufferSet._getFirstEmptyBuffer()==null) collapse();
				newBuffer();
				if (!currentBufferToFill.isAllocated) currentBufferToFill.allocate();
				currentBufferToFill.isSorted = false;
				bufferValues = currentBufferToFill.values.elements();
				bufferSize = 0;
			}

			bufferValues[bufferSize++] = valuesToAdd[i];
			if (bufferSize == k) { // full
				currentBufferToFill.values.setSize(bufferSize);
				currentBufferToFill = null;
			}
		}
	}
	if (this.currentBufferToFill != null) {
		this.currentBufferToFill.values.setSize(bufferSize);
	}
	
	this.totalElementsFilled += to-from+1;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:49,代码来源:DoubleQuantileEstimator.java


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