コード例 #1
0
  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;
  }
コード例 #2
0
  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());
  }
コード例 #3
0
  @Override
  public double get(int row, int col) {
    if (row == col) {
      return diag.get(row);
    }

    return -backing.get(row, col);
  }
コード例 #4
0
  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);
      }
    }
  }
コード例 #5
0
  @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];
    }
  }
コード例 #6
0
 private void computeDiag() {
   diag = new DenseVector(backing.numRows());
   backing.rowSums(diag.getData());
   MatrixUtils.add(diag, 1d);
 }