public SimpleSiteDetails( double[][] categoryPatternConditionalProbabilities, boolean isLoggedConditionals, SubstitutionModel model, int numberOfPatterns, int[] sitePatternMatchup, int numberOfSites, double[] siteLikelihoods) { final int numberOfCategories = model.getNumberOfTransitionCategories(); this.siteLikelihoods_ = pal.misc.Utils.getCopy(siteLikelihoods); this.siteLogLikelihoods_ = new double[numberOfSites]; double llh = 0; for (int i = 0; i < numberOfSites; i++) { this.siteLogLikelihoods_[i] = Math.log(this.siteLikelihoods_[i]); llh += this.siteLogLikelihoods_[i]; } System.out.println("Total:" + llh); if (isLoggedConditionals) { this.categoryPatternConditionalProbabilities_ = convertLogged( categoryPatternConditionalProbabilities, numberOfCategories, numberOfPatterns); } else { this.categoryPatternConditionalProbabilities_ = pal.misc.Utils.getCopy(categoryPatternConditionalProbabilities); } this.numberOfSites_ = numberOfSites; this.sitePatternMatchup_ = pal.misc.Utils.getCopy(sitePatternMatchup); this.patternPosteriors_ = new double[numberOfPatterns][numberOfCategories]; for (int p = 0; p < numberOfPatterns; p++) { double total = 0; for (int c = 0; c < numberOfCategories; c++) { total += categoryPatternConditionalProbabilities[c][p]; } for (int c = 0; c < numberOfCategories; c++) { patternPosteriors_[p][c] = categoryPatternConditionalProbabilities[c][p] / total; } } this.model_ = model; }
/** * Create a SimpleUnconstrainedLikelihoodModel instance * * @param base The base LHCalculator generator to utilise * @param model The substitution model * @return An appropriate UnconstrianedLikelihoodModel instance */ public static final Instance createInstance(LHCalculator.Factory base, SubstitutionModel model) { return new InstanceImpl( base.createSeries(model.getNumberOfTransitionCategories(), model.getDataType()), model); }
public String getSubstitutionModelSummary() { return model_.toString(); }