protected double calculateLogFieldLikelihood() { if (!intervalsKnown) { // intervalsKnown -> false when handleModelChanged event occurs in super. wrapSetupIntervals(); setupGMRFWeights(); intervalsKnown = true; } double currentLike = 0; DenseVector diagonal1 = new DenseVector(fieldLength); DenseVector currentGamma = new DenseVector(popSizeParameter.getParameterValues()); SymmTridiagMatrix currentQ = getScaledWeightMatrix( precisionParameter.getParameterValue(0), lambdaParameter.getParameterValue(0)); currentQ.mult(currentGamma, diagonal1); // currentLike += 0.5 * logGeneralizedDeterminant(currentQ) - 0.5 * // currentGamma.dot(diagonal1); currentLike += 0.5 * (fieldLength - 1) * Math.log(precisionParameter.getParameterValue(0)) - 0.5 * currentGamma.dot(diagonal1); if (lambdaParameter.getParameterValue(0) == 1) { currentLike -= (fieldLength - 1) / 2.0 * LOG_TWO_TIMES_PI; } else { currentLike -= fieldLength / 2.0 * LOG_TWO_TIMES_PI; } return currentLike; }
public static void main(String... args) { Collection<Double> goldVec = VSMUtil.getGoldStandard().values(); DenseVector goldVector = new DenseVector(goldVec.size()); int idx = 0; for (double gold : goldVec) { goldVector.add(idx, gold); idx++; } System.out.println(goldVector.size()); }
@Override public double get(int row, int col) { if (row == col) { return diag.get(row); } return -backing.get(row, col); }
protected void computeDegrees(Organism organism) throws ApplicationException { Collection<Collection<Long>> groupedNetworks = getAllNetworks(organism); degreesInOrganism.zero(); DenseVector degreesInNetwork = new DenseVector(numGenes); for (Collection<Long> networks : groupedNetworks) { for (long networkId : networks) { degreesInNetwork.zero(); Network network = cache.getNetwork(Data.CORE, organism.getId(), networkId); SymMatrix networkData = network.getData(); networkData.columnSums(degreesInNetwork.getData()); degreesInOrganism.add(degreesInNetwork); } } }
@Override // todo: update to use vector ops public void multAdd(double alpha, double[] x, double[] y) { int l = backing.numRows(); for (int i = 0; i < l; i++) { y[i] = -y[i]; } backing.multAdd(x, y); for (int i = 0; i < l; i++) { y[i] = diag.get(i) * x[i] - y[i]; } }
private void computeDiag() { diag = new DenseVector(backing.numRows()); backing.rowSums(diag.getData()); MatrixUtils.add(diag, 1d); }