本文整理汇总了Java中org.jblas.DoubleMatrix.sum方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleMatrix.sum方法的具体用法?Java DoubleMatrix.sum怎么用?Java DoubleMatrix.sum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jblas.DoubleMatrix
的用法示例。
在下文中一共展示了DoubleMatrix.sum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeLambdaSum
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
public double computeLambdaSum(int t, int childIdx1, int childIdx2) {
double lambda;
DoubleMatrix F,Y;
Y = ts.getYs()[t];
F = ts.getFs()[t];
DoubleMatrix pa, pvec1, pvec2;
pvec1 = stateProbabilities.getStateProbsFromIndex(childIdx1);
pvec2 = stateProbabilities.getStateProbsFromIndex(childIdx2);
/* previous version */
DoubleMatrix coalRates = DoubleMatrix.zeros(numStates, numStates);
for (int k = 0; k < numStates; k++) {
for (int l = 0; l < numStates; l++) {
final double Yk = Y.get(k);
final double Yl = Y.get(l);
//System.out.println("numStates="+numStates+"dim:"+F.rows+", "+F.columns);
lambda = F.get(k,l) / (Yk*Yl)
* (pvec1.get(k) * pvec2.get(l)
+ pvec1.get(l) * pvec2.get(k));
coalRates.put(k, l, lambda);
}
}
lambda = coalRates.sum();
pa = coalRates.rowSums().div(lambda).transpose(); // row-vector
/* pa := new state probabilities of the lineage dt after coalescing */
return lambda;
}
示例2: computeMapping
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
private DoubleMatrix computeMapping(DoubleMatrix x) {
DoubleMatrix alphas = MatrixFunctions.pow(
MatrixFunctions.pow(
this.highDimControlPoints.subRowVector(x),
2
).rowSums(),
-1
);
double alpha = alphas.sum();
DoubleMatrix xTilde = this.highDimControlPoints.mulColumnVector(alphas).columnSums().div(alpha);
DoubleMatrix yTilde = this.lowDimControlPoints.mulColumnVector(alphas).columnSums().div(alpha);
DoubleMatrix xHats = this.highDimControlPoints.subRowVector(xTilde);
@SuppressWarnings("SuspiciousNameCombination")
DoubleMatrix yHats = this.lowDimControlPoints.subRowVector(yTilde);
DoubleMatrix sqrtAlphas = MatrixFunctions.sqrt(alphas);
DoubleMatrix A = xHats.mulColumnVector(sqrtAlphas);
DoubleMatrix B = yHats.mulColumnVector(sqrtAlphas);
DoubleMatrix[] svdComposition = Singular.sparseSVD(A.transpose().mmul(B));
DoubleMatrix U = svdComposition[0];
DoubleMatrix V = svdComposition[2];
DoubleMatrix M = U.mmul(V);
return x.sub(xTilde).mmul(M).add(yTilde);
}
示例3: processCoalEvent
import org.jblas.DoubleMatrix; //导入方法依赖的package包/类
protected double processCoalEvent(int t, int currTreeInterval) {
List<DoubleMatrix> coalVectors = stateProbabilities.getCoalescentVectors(intervals, currTreeInterval);
DoubleMatrix pvec1, pvec2;
pvec1 = coalVectors.get(0);
pvec2 = coalVectors.get(1);
List<Node> parentLines = intervals.getLineagesAdded(currTreeInterval);
if (parentLines.size() > 1) throw new RuntimeException("Unsupported coalescent at non-binary node");
//Add parent to activeLineage and initialise parent's state prob vector
Node parentNode = parentLines.get(0);
//Compute parent lineage state probabilities in p
DoubleMatrix F,Y;
Y = ts.getYs()[t];
F = ts.getFs()[t];
if (forgiveYInput.get()) {
Y.maxi(1.0);
} else { // however, Y_i > 1e-12 by default
Y.maxi(1e-12);
}
double lambda;
/* Compute Lambda Sum */
DoubleMatrix pa;
DoubleMatrix pi_Y = pvec1.div(Y);
pi_Y.reshape(numStates, 1);
DoubleMatrix pj_Y = pvec2.div(Y);
pj_Y.reshape(numStates, 1);
pa = pi_Y.mul(F.mmul(pj_Y));
pa.addi(pj_Y.mul(F.mmul(pi_Y)));
pa.reshape(1,numStates);
lambda = pa.sum();
pa.divi(lambda);
stateProbabilities.addLineage(parentNode.getNr(),pa);
sp[parentNode.getNr() - nrSamples] = (pa);
//Remove child lineages
List<Node> coalLines = intervals.getLineagesRemoved(currTreeInterval);
stateProbabilities.removeLineageNr(coalLines.get(0).getNr() );
stateProbabilities.removeLineageNr(coalLines.get(1).getNr());
if (fsCorrectionsInput.get()) {
doFiniteSizeCorrections(parentNode,pa);
}
return lambda;
}