Package pal.eval

Class ConditionalProbabilityStore

  • All Implemented Interfaces:
    java.io.Serializable

    public final class ConditionalProbabilityStore
    extends java.lang.Object
    implements java.io.Serializable

    Title: ConditionalProbabilityStore (was ConditionalLikelihoodStore)

    Description: A container class for various bits of data relating to the conditional likelihood. Things stored include the conditional likelihood, an scale factors and whether the current conditional likelihoods were created from cached data.

    Version:
    1.0
    Author:
    Matthew Goode
    See Also:
    Serialized Form
    • Constructor Detail

      • ConditionalProbabilityStore

        public ConditionalProbabilityStore​(int numberOfCategories,
                                           int numberOfStates)
    • Method Detail

      • isHasExtraProcessor

        public final boolean isHasExtraProcessor()
      • getPatternCapacity

        public int getPatternCapacity()
      • getCurrentConditionalProbabilities

        public double[][][] getCurrentConditionalProbabilities()
        Used for getting access to the internal conditional probability store when the data is not to be directly changed.
        Returns:
        An array of arrays of arrays, in the form [category][pattern][state]
      • getCurrentConditionalProbabilities

        public double[][] getCurrentConditionalProbabilities​(int category)
        Used for getting access to the internal conditional probability store when the data is not to be directly changed.
        Parameters:
        category - the transition category of interest
        Returns:
        An array of arrays in the form [pattern][state]
      • getConditionalProbabilityAccess

        public double[][][] getConditionalProbabilityAccess​(int numberOfPatterns,
                                                            boolean resultsBasedOnCachedData)
        Use this when access the internal conditional likelihood store for the purpose of changing the contents.
        Parameters:
        numberOfPatterns - An indication of how much space will be required. The result will always be big enough to accomodate the requested number of patterns.
        resultsBasedOnCachedData - An indication of whether the new conditionals about to be stored are based on cached data
        Returns:
      • getConditionalProbabilityAccessNoChangeData

        public double[][][] getConditionalProbabilityAccessNoChangeData​(int numberOfPatterns,
                                                                        boolean resultsBasedOnCachedData)
        Use this when access the internal conditional likelihood store for the purpose of changing the contents. This version will not automatically resize array, and will throw an exception if the numberOfPatterns requested is incompatible with the current contents of this store.
        Parameters:
        numberOfPatterns - An indication of how much space will be required. An exception is thrown if this number of patterns cannot be accomodated without being resized.
        resultsBasedOnCachedData - An indication of whether the new conditionals about to be stored are based on cached data
        Returns:
        Throws:
        java.lang.IllegalArgumentException - if incompatible number of patterns
      • getIncompleteConditionalProbabilityAccess

        public double[][][] getIncompleteConditionalProbabilityAccess​(int numberOfPatterns,
                                                                      boolean resultsBasedOnCachedData,
                                                                      boolean fix)
        Use this when access the internal conditional likelihood store for the purpose of changing the contents. The state arrays will not be created.
        Parameters:
        numberOfPatterns - An indication of how much space will be required. The result will always be big enough to accomodate the requested number of patterns.
        resultsBasedOnCachedData - An indication of whether the new conditionals about to be stored are based on cached data
        Returns:
      • calculateLogLikelihood

        public double calculateLogLikelihood​(double[] categoryProbabilities,
                                             double[] equilibriumFrequencies,
                                             int[] patternWeights,
                                             int numberOfPatterns)
      • calculateLogLikelihood

        public double calculateLogLikelihood​(double[] categoryProbabilities,
                                             double[] equilibriumFrequencies,
                                             int numberOfPatterns)
      • calculatePatternLogLikelihoods

        public double[] calculatePatternLogLikelihoods​(double[] categoryProbabilities,
                                                       double[] equilibriumFrequencies,
                                                       int numberOfPatterns)
      • calculateCategoryPatternConditionalProbabilities

        public double[][] calculateCategoryPatternConditionalProbabilities​(double[] categoryProbabilities,
                                                                           double[] equilibriumFrequencies,
                                                                           int numberOfPatterns)
        Calculate the conditional probabilities for each ancestral state at each site pattern, multiplied by related equilibrium frequencies
        Parameters:
        categoryProbabilities - The prior probability of a site belonging to a particular category
        equilibriumFrequencies - the prior probabibilities of seeing a particular state
        numberOfPatterns - The number of patterns
        Returns:
        the related conditional probability array organised [category][pattern]
      • isBasedOnCachedData

        public boolean isBasedOnCachedData()
      • setBasedOnCachedData

        public void setBasedOnCachedData​(boolean v)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toString

        public java.lang.String toString​(int numberOfPatterns)