pal.eval
Class ConditionalProbabilityStore

java.lang.Object
  extended bypal.eval.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.

See Also:
Serialized Form

Nested Class Summary
static interface ConditionalProbabilityStore.ExtraProcessor
           
 
Constructor Summary
ConditionalProbabilityStore(int numberOfCategories, int numberOfStates)
           
ConditionalProbabilityStore(int numberOfCategories, int numberOfStates, ConditionalProbabilityStore.ExtraProcessor extraProcessor)
           
 
Method Summary
 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
 double calculateLogLikelihood(double[] categoryProbabilities, double[] equilibriumFrequencies, int numberOfPatterns)
           
 double calculateLogLikelihood(double[] categoryProbabilities, double[] equilibriumFrequencies, int[] patternWeights, int numberOfPatterns)
           
 double[] calculatePatternLogLikelihoods(double[] categoryProbabilities, double[] equilibriumFrequencies, int numberOfPatterns)
           
 double[][][] getConditionalProbabilityAccess(int numberOfPatterns, boolean resultsBasedOnCachedData)
          Use this when access the internal conditional likelihood store for the purpose of changing the contents.
 double[][][] getConditionalProbabilityAccessNoChangeData(int numberOfPatterns, boolean resultsBasedOnCachedData)
          Use this when access the internal conditional likelihood store for the purpose of changing the contents.
 ConditionalProbabilityStore getCopy()
          Cloning
 double[][][] getCurrentConditionalProbabilities()
          Used for getting access to the internal conditional probability store when the data is not to be directly changed.
 double[][] getCurrentConditionalProbabilities(int category)
          Used for getting access to the internal conditional probability store when the data is not to be directly changed.
 ConditionalProbabilityStore.ExtraProcessor getExtraProcessor()
           
 double[][][] getIncompleteConditionalProbabilityAccess(int numberOfPatterns, boolean resultsBasedOnCachedData, boolean fix)
          Use this when access the internal conditional likelihood store for the purpose of changing the contents.
 int getPatternCapacity()
           
 boolean isBasedOnCachedData()
           
 boolean isHasExtraProcessor()
           
 void setBasedOnCachedData(boolean v)
           
 java.lang.String toString()
           
 java.lang.String toString(int numberOfPatterns)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConditionalProbabilityStore

public ConditionalProbabilityStore(int numberOfCategories,
                                   int numberOfStates)

ConditionalProbabilityStore

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

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:
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()

toString

public java.lang.String toString(int numberOfPatterns)