Package pal.eval

Class ConditionalProbabilityStore

java.lang.Object
pal.eval.ConditionalProbabilityStore
All Implemented Interfaces:
Serializable

public final class ConditionalProbabilityStore extends Object implements 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:
  • Constructor Details

    • ConditionalProbabilityStore

      public ConditionalProbabilityStore(int numberOfCategories, int numberOfStates)
    • ConditionalProbabilityStore

      public ConditionalProbabilityStore(int numberOfCategories, int numberOfStates, ConditionalProbabilityStore.ExtraProcessor extraProcessor)
  • Method Details

    • getCopy

      public final ConditionalProbabilityStore getCopy()
      Cloning
      Returns:
      a copy of this conditional probability store
    • isHasExtraProcessor

      public final boolean isHasExtraProcessor()
    • getExtraProcessor

      public final ConditionalProbabilityStore.ExtraProcessor getExtraProcessor()
    • 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:
      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 String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(int numberOfPatterns)