Ejemplo n.º 1
0
  public GMRFSkyrideLikelihood(
      List<Tree> treeList,
      Parameter popParameter,
      Parameter groupParameter,
      Parameter precParameter,
      Parameter lambda,
      Parameter beta,
      MatrixParameter dMatrix,
      boolean timeAwareSmoothing,
      boolean rescaleByRootHeight) {

    super(GMRFSkyrideLikelihoodParser.SKYLINE_LIKELIHOOD);

    this.popSizeParameter = popParameter;
    this.groupSizeParameter = groupParameter;
    this.precisionParameter = precParameter;
    this.lambdaParameter = lambda;
    this.betaParameter = beta;
    this.dMatrix = dMatrix;
    this.timeAwareSmoothing = timeAwareSmoothing;
    this.rescaleByRootHeight = rescaleByRootHeight;

    addVariable(popSizeParameter);
    addVariable(precisionParameter);
    addVariable(lambdaParameter);
    if (betaParameter != null) {
      addVariable(betaParameter);
    }

    setTree(treeList);

    int correctFieldLength = getCorrectFieldLength();

    if (popSizeParameter.getDimension() <= 1) {
      // popSize dimension hasn't been set yet, set it here:
      popSizeParameter.setDimension(correctFieldLength);
    }

    fieldLength = popSizeParameter.getDimension();
    if (correctFieldLength != fieldLength) {
      throw new IllegalArgumentException(
          "Population size parameter should have length " + correctFieldLength);
    }

    // Field length must be set by this point
    wrapSetupIntervals();
    coalescentIntervals = new double[fieldLength];
    storedCoalescentIntervals = new double[fieldLength];
    sufficientStatistics = new double[fieldLength];
    storedSufficientStatistics = new double[fieldLength];

    setupGMRFWeights();

    addStatistic(new DeltaStatistic());

    initializationReport();

    /* Force all entries in groupSizeParameter = 1 for compatibility with Tracer */
    if (groupSizeParameter != null) {
      for (int i = 0; i < groupSizeParameter.getDimension(); i++)
        groupSizeParameter.setParameterValue(i, 1.0);
    }
  }