• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DoubleArrayList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



DoubleArrayList类属于cern.colt.list包,在下文中一共展示了DoubleArrayList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: validierung

import cern.colt.list.DoubleArrayList; //导入依赖的package包/类
public void validierung(DoubleArrayList trendbereinigtezeitreihe, DoubleMatrix2D matrixPhi, int p) {

		double prognosewert = 0;
		double realisierungsWert = trendbereinigtezeitreihe.get(trendbereinigtezeitreihe.size() - 1);
		Trendgerade trend = new Trendgerade(new double[1]);
		realisierungsWert = realisierungsWert + trend.getValue(p);
		// Ein Durchlauf findet den Gewichtungsfaktor Phi und den dazu passenden
		// Vergangenheitswert.
		// Hier wird der Prognosewert für den Zeitpunkt 0 berechnet
		for (int t = 0; t < p; t++) {
			prognosewert = prognosewert
					+ (matrixPhi.get(t, 0) * trendbereinigtezeitreihe.get(trendbereinigtezeitreihe.size() - (t + 2)));
		}
		prognosewert = prognosewert + trend.getValue(p);
		// Berechnung der prozentualen Abweichung
		double h = prognosewert / (realisierungsWert / 100);
		// Die Variable abweichung enthält die Abweichung in %, abweichung =1
		// --> Die Abweichung beträgt 1%
		double abweichung = Math.abs(h - 100);
		setAbweichung(abweichung);
	}
 
开发者ID:DHBW-Karlsruhe,项目名称:businesshorizon2,代码行数:22,代码来源:AnalysisTimeseries.java


示例3: SparseMultSparseTranspose

import cern.colt.list.DoubleArrayList; //导入依赖的package包/类
static public List<DoubleMatrix1D> SparseMultSparseTranspose(List<DoubleMatrix1D> A,
		List<DoubleMatrix1D> B) {
	int m = A.size();
	int n = A.get(0).size();
	int p = B.size();
	List<DoubleMatrix1D> C = null;
	if (C==null) {
		C = new ArrayList<DoubleMatrix1D>();
		for (int i = 0; i < m; ++i) {
			C.add(new ColtSparseVector(p));
		}
	}
	if (B.get(0).size() != n)
		throw new IllegalArgumentException("Matrix2D inner dimensions must agree.");
	for (int i = 0; i < m; ++i) {
		IntArrayList indexList = new IntArrayList();
		DoubleArrayList valueList = new DoubleArrayList();
		A.get(i).getNonZeros(indexList, valueList);
		for (int j = 0; j < p; ++j) {
			if (B.get(j).size() != A.get(i).size())
				throw new IllegalArgumentException("Matrix2D inner dimensions must agree.");
			double sum = 0.0;
			for (int k = 0; k < indexList.size(); ++k) {
				int index = indexList.get(k);
				double value1 = valueList.get(k);
				double value2 = B.get(j).getQuick(index); 
				if (value1 != 0 || value2 != 0) { 
					sum += value1 * value2;
				}
			}
			C.get(i).setQuick(j, sum);
		}	
	}
	return C;
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:36,代码来源:Matrix2DUtil.java


示例4: getSparseTranspose

import cern.colt.list.DoubleArrayList; //导入依赖的package包/类
static public List<DoubleMatrix1D> getSparseTranspose(List<DoubleMatrix1D> A) {
	List<DoubleMatrix1D> AT = new ArrayList<DoubleMatrix1D>();
	for (int i = 0; i < A.get(0).size(); ++i) {
		AT.add(new ColtSparseVector(A.size()));
	}
	for (int i = 0; i < A.size(); ++i) {
		IntArrayList indexList = new IntArrayList();
		DoubleArrayList valueList = new DoubleArrayList();
		A.get(i).getNonZeros(indexList, valueList);
		for (int k = 0; k < indexList.size(); ++k) {
			int index = indexList.get(k);
			double value = valueList.get(k);
			AT.get(index).set(i, value);
		}
	}
	return AT;
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:18,代码来源:Matrix2DUtil.java


示例5: productQuick

import cern.colt.list.DoubleArrayList; //导入依赖的package包/类
static public double productQuick(DoubleMatrix1D v1, DoubleMatrix1D v2) {
		IntArrayList indexList = new IntArrayList();
		DoubleArrayList valueList = new DoubleArrayList();
		v1.getNonZeros(indexList, valueList);
		double prod = 0.0;
		for (int i = 0; i < indexList.size(); ++i) {
			double temp = v2.getQuick(indexList.getQuick(i));
			if (temp != 0.0) {
				prod += valueList.getQuick(i) * temp;
			}
		}

//		for (int i = 0; i < v1.size(); ++i) {
//			double temp1 = v1.getQuick(i);
//			double temp2 = v2.getQuick(i);
//			if (temp1 != 0.0 || temp2 != 0.0) {
//				prod += temp1 * temp2;
//			}
//		}
		return prod;
	}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:22,代码来源:Matrix2DUtil.java


示例6: computeCosineSimilarity

import cern.colt.list.DoubleArrayList; //导入依赖的package包/类
public static double computeCosineSimilarity(IntArrayList indexA, DoubleArrayList valueA, DoubleMatrix1D B, DoubleArrayList valueB)
{
	double sim = -1;
	
	double num = 0;
	double den = 0;
	double den_1 = 0;
	double den_2 = 0;

	num = Matrix2DUtil.productQuick(indexA, valueA, B);
	den_1 = Matrix2DUtil.getSqrSum(valueA);
	den_2 = Matrix2DUtil.getSqrSum(valueB);
	den = Math.sqrt(den_1) * Math.sqrt(den_2);
	if(den == 0)
		return 0;
	sim = num/den;
	return sim;
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:19,代码来源:SimilarityMeasures.java


示例7: addNoise

import cern.colt.list.DoubleArrayList; //导入依赖的package包/类
public static void addNoise(DoubleMatrix2D s) {
  IntArrayList is = new IntArrayList();
  IntArrayList ks = new IntArrayList();
  DoubleArrayList vs = new DoubleArrayList();            
  s.getNonZeros(is, ks, vs);
  
  for (int j=0; j<is.size(); j++) {
    int i = is.get(j);
    int k = ks.get(j);
    double v = vs.get(j);
    v = v + (EPSILON * v + REALMIN100) * Math.random();
    s.setQuick(i, k, v);
  }    
}
 
开发者ID:lovro-i,项目名称:apro,代码行数:15,代码来源:Utils.java


示例8: add

import cern.colt.list.DoubleArrayList; //导入依赖的package包/类
/**
 * Adds the specified element to the receiver.
 *
 * @param element element to be appended.
 */
public synchronized void add(double element) {
	// prototyping implementation; inefficient; TODO
	this.addAllOf(new DoubleArrayList(new double[] {element}));
	/*
	sumSquares += element * element;
	if (this.done == 0) { // initial setup
		this.min = element;
		this.max = element;
	}
	else {
		if (element < this.min) this.min = element;
		if (element > this.max) this.max = element;

		double oldMean = this.mean;
		this.mean += (element - this.mean)/(done+1);
		this.sumsq += (element-this.mean)*(element-oldMean); // cool, huh?
	}
	this.done++;
	*/
}
 
开发者ID:ContentWise,项目名称:aida,代码行数:26,代码来源:StaticBin1D.java


示例9: 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 list 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).
 * @throws IndexOutOfBoundsException if <tt>list.size()&gt;0 && (from&lt;0 || from&gt;to || to&gt;=list.size())</tt>.
 */
public synchronized void addAllOfFromTo(DoubleArrayList list, int from, int to) {
	//if (this.arguments == null) setUpCache();
	synchronized (arguments) {
		// prepare arguments
		arguments[0] = this.min;
		arguments[1] = this.max;
		arguments[2] = this.sum;
		arguments[3] = this.sum_xx;

		Descriptive.incrementalUpdate(list, from, to, arguments);

		// store the new parameters back
		this.min = arguments[0];
		this.max = arguments[1];
		this.sum = arguments[2];
		this.sum_xx = arguments[3];

		this.size += to-from+1;
	}
}
 
开发者ID:ContentWise,项目名称:aida,代码行数:29,代码来源:StaticBin1D.java


示例10: 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 list 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).
 * @throws IndexOutOfBoundsException if <tt>list.size()&gt;0 && (from&lt;0 || from&gt;to || to&gt;=list.size())</tt>.
 */
public synchronized void addAllOfFromTo(DoubleArrayList list, int from, int to) {
	super.addAllOfFromTo(list, from, to);
	
	if (this.sumOfPowers != null) {
		//int max_k = this.min_k + this.sumOfPowers.length-1;
		Descriptive.incrementalUpdateSumsOfPowers(list, from, to, 3, getMaxOrderForSumOfPowers(), this.sumOfPowers);
	}

	if (this.hasSumOfInversions) {
		this.sumOfInversions += Descriptive.sumOfInversions(list, from, to);
	}
	
	if (this.hasSumOfLogarithms) {
		this.sumOfLogarithms += Descriptive.sumOfLogarithms(list, from, to);
	}
}
 
开发者ID:ContentWise,项目名称:aida,代码行数:25,代码来源:MightyStaticBin1D.java


示例11: testLargeMatrix_build1

import cern.colt.list.DoubleArrayList; //导入依赖的package包/类
/** Tests whether buildSolver works. */
@Test
public final void testLargeMatrix_build1()
{
	for(int size=100;size<2100;size+=400)
		for(int elemsPerColExp=0;elemsPerColExp< 7;elemsPerColExp++)
		{
			int elemsPerColExpected = (int)Math.pow(2, elemsPerColExp);
			DoubleMatrix2D matrix = buildSolver(size,elemsPerColExpected).toDoubleMatrix2D();
			
			IntArrayList CoordX = new IntArrayList(),CoordY = new IntArrayList();DoubleArrayList values = new DoubleArrayList();
			matrix.getNonZeros(CoordY, CoordX, values);
			int nz=CoordX.size();
			int diagElements = 0, nondiagElements = 0;
			for(int i=0;i<nz;++i)
			{
				if (CoordX.getQuick(i) == CoordY.getQuick(i))
				{
					Assert.assertEquals(1, values.getQuick(i),Configuration.fpAccuracy);diagElements++;
				}
				else nondiagElements++;
			}
			Assert.assertEquals(size, diagElements);
			Assert.assertEquals(size*(elemsPerColExpected-1), nondiagElements);
		}
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:27,代码来源:TestSolver.java


示例12: learnStateFromRegions

import cern.colt.list.DoubleArrayList; //导入依赖的package包/类
public void learnStateFromRegions(int state,
                                  Collection<Region> regions) throws NotFoundException {
    DoubleArrayList values = new DoubleArrayList();
    for (Region r : regions) {
        data.window(r.getChrom(), r.getStart(), r.getEnd());
        for (int i = 0; i < data.getCount(); i++) {
            for (int j = 0; j < data.getReplicates(i); j++) {
                double d = Math.log(data.getRatio(i,j));
                if (!(Double.isInfinite(d) || Double.isNaN(d))) {
                    values.add(d);
                }
            }
        }
    }
    double mean = Descriptive.mean(values);
    double std = Descriptive.standardDeviation(Descriptive.variance(values.size(),
                                                                    Descriptive.sum(values),
                                                                    Descriptive.sumOfSquares(values)));
    /* TODO : verify that OpdfGaussian wants the variance rather than the stddev */
    pdfs.set(state, new OpdfGaussian(mean, std * std));
}
 
开发者ID:shaunmahony,项目名称:multigps-archive,代码行数:22,代码来源:CGHCallExpander.java


示例13: quantileElements

import cern.colt.list.DoubleArrayList; //导入依赖的package包/类
/**
 * Computes the specified quantile elements over the values previously added.
 * @param phis the quantiles for which elements are to be computed. Each phi must be in the interval (0.0,1.0]. <tt>phis</tt> must be sorted ascending.
 * @return the approximate quantile elements.
 */
public DoubleArrayList quantileElements(DoubleArrayList phis) {
	if (precomputeEpsilon<=0.0) return super.quantileElements(phis);
	
	int quantilesToPrecompute = (int) Utils.epsilonCeiling(1.0 / precomputeEpsilon);
	/*
	if (phis.size() > quantilesToPrecompute) {
		// illegal use case!
		// we compute results, but loose explicit approximation guarantees.
		return super.quantileElements(phis);
	}
	*/
 
	//select that quantile from the precomputed set that corresponds to a position closest to phi.
	phis = phis.copy();
	double e = precomputeEpsilon;
	for (int index=phis.size(); --index >= 0;) {
		double phi = phis.get(index);
		int i = (int) Math.round( ((2.0*phi/e) - 1.0 ) / 2.0); // finds closest
		i = Math.min(quantilesToPrecompute-1, Math.max(0,i));
		double augmentedPhi = (e/2.0)*(1+2*i);
		phis.set(index,augmentedPhi);				
	}
	
	return super.quantileElements(phis);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:31,代码来源:UnknownDoubleQuantileEstimator.java


示例14: observedEpsilonAtPhi

import cern.colt.list.DoubleArrayList; //导入依赖的package包/类
/**
 * This method was created in VisualAge.
 * @return double[]
 * @param values cern.it.hepodbms.primitivearray.DoubleArrayList
 * @param phis double[]
 */
public static double observedEpsilonAtPhi(double phi, ExactDoubleQuantileFinder exactFinder, DoubleQuantileFinder approxFinder) {
	int N = (int) exactFinder.size();
	
	int exactRank = (int) Utils.epsilonCeiling(phi * N) - 1;
	//System.out.println("exactRank="+exactRank);
	exactFinder.quantileElements(new DoubleArrayList(new double[] {phi})).get(0); // just to ensure exactFinder is sorted
	double approxElement = approxFinder.quantileElements(new DoubleArrayList(new double[] {phi})).get(0); 
	//System.out.println("approxElem="+approxElement);
	IntArrayList approxRanks = binaryMultiSearch(exactFinder.buffer, approxElement);
	int from = approxRanks.get(0);
	int to = approxRanks.get(1);

	int distance;
	if (from<=exactRank && exactRank<=to) distance = 0;
	else {
		if (from>exactRank) distance=Math.abs(from-exactRank);
		else distance=Math.abs(exactRank-to);
	}

	double epsilon = (double)distance / (double)N;
	return epsilon;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:29,代码来源:QuantileFinderTest.java


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


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


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


示例18: median

import cern.colt.list.DoubleArrayList; //导入依赖的package包/类
/**
 * Returns the median of a sorted data sequence.
 *
 * @param sortedData the data sequence; <b>must be sorted ascending</b>.
 */
public static double median(DoubleArrayList sortedData) {
	return quantile(sortedData, 0.5);
	/*
	double[] sortedElements = sortedData.elements();
	int n = sortedData.size();
	int lhs = (n - 1) / 2 ;
	int rhs = n / 2 ;
  
	if (n == 0) return 0.0 ;

	double median;
	if (lhs == rhs) median = sortedElements[lhs] ;
	else median = (sortedElements[lhs] + sortedElements[rhs])/2.0 ;

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


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


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FontIcon类代码示例发布时间:2022-05-21
下一篇:
Java TextFieldStyle类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap