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


Java SimpleSVD.getW方法代码示例

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


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

示例1: getSigmaPoints

import org.ejml.simple.SimpleSVD; //导入方法依赖的package包/类
/**
 * Returns 2n+k sigma points starting with mean as the first point
 * 
 * @param mean
 * @param cov
 * @param no
 * @param k
 * @return
 */
private static List<SimpleMatrix> getSigmaPoints(SimpleMatrix mean, SimpleMatrix cov, int no, int k) {
	List<SimpleMatrix> resultVectors = new ArrayList<SimpleMatrix>();

	int n = cov.numRows();
	SimpleSVD<?> svd = cov.svd(true);
	SimpleMatrix U = svd.getU();
	SimpleMatrix S = svd.getW();

	S = U.mult(MatrixOps.elemSqrt(S)).scale(Math.sqrt(n + k));

	for (int i = 0; i < S.numCols(); i++) {
		SimpleMatrix columnVector = S.extractVector(false, i);
		SimpleMatrix negColumnVector = S.extractVector(false, i).scale(-1);
		resultVectors.add(columnVector.plus(mean));
		resultVectors.add(negColumnVector.plus(mean));
	}
	if (k != 0)
		resultVectors.add(mean);

	return resultVectors;
}
 
开发者ID:kevoree,项目名称:kevoree-brain,代码行数:31,代码来源:Hellinger.java

示例2: split

import org.ejml.simple.SimpleSVD; //导入方法依赖的package包/类
/**
 * Splits a single component distribution into two components as described in the oKDE-paper.
 * @return a TwoComponentDistribution
 */
public TwoComponentDistribution split(double parentWeight){
	SimpleSVD<?> svd = mGlobalCovariance.svd(true);
	SimpleMatrix S = svd.getW();
	SimpleMatrix V = svd.getV();
	SimpleMatrix d = S.extractDiag();
	double max = MatrixOps.maxVectorElement(d);
	int maxIndex = MatrixOps.maxVectorElementIndex(d);
	int len = mGlobalCovariance.numRows();
	SimpleMatrix M = new SimpleMatrix(len,1);
	M.set(maxIndex, 0, 1.0d);
	SimpleMatrix dMean = V.mult(M).scale(0.5*Math.sqrt(max));
	SimpleMatrix meanSplit1 = mGlobalMean.plus(dMean);
	SimpleMatrix meanSplit2 = mGlobalMean.minus(dMean);
	
	SimpleMatrix dyadMean = mGlobalMean.mult(mGlobalMean.transpose());
	SimpleMatrix dyadMeanSplit1 = meanSplit1.mult(meanSplit1.transpose());
	SimpleMatrix dyadMeanSplit2 = meanSplit2.mult(meanSplit2.transpose());
	SimpleMatrix covSplit = mGlobalCovariance.plus(dyadMean).minus(dyadMeanSplit1.plus(dyadMeanSplit2).scale(0.5));
	
	SimpleMatrix[] means = {meanSplit1, meanSplit2};
	SimpleMatrix[] covariances = {covSplit, covSplit};
	double[] weights = {0.5, 0.5};
	TwoComponentDistribution splitDist = null;
	try {
		splitDist = new TwoComponentDistribution(weights, means, covariances, mBandwidthMatrix);
		splitDist.setGlobalWeight(parentWeight*mGlobalWeight);
		splitDist.setGlobalCovariance(mGlobalCovariance);
		splitDist.setGlobalMean(mGlobalMean);
	} catch (TooManyComponentsException e) {
		// cant be thrown
	}
	return splitDist;
}
 
开发者ID:kevoree,项目名称:kevoree-brain,代码行数:38,代码来源:OneComponentDistribution.java


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