jebl.evolution.substmodel
Class AbstractRateMatrix

java.lang.Object
  extended by jebl.evolution.substmodel.AbstractRateMatrix
All Implemented Interfaces:
Serializable, Cloneable, RateMatrix
Direct Known Subclasses:
AminoAcidModel

public abstract class AbstractRateMatrix
extends Object
implements RateMatrix

abstract base class for all rate matrices

Author:
Korbinian Strimmer, Alexei Drummond
See Also:
Serialized Form

Constructor Summary
protected AbstractRateMatrix(int dim)
           
 
Method Summary
 int getDimension()
           
 double[] getEquilibriumFrequencies()
           
 double getEquilibriumFrequency(int i)
           
protected  double[] getFrequencies()
           
 double[][] getRelativeRates()
           
 SequenceType getSequenceType()
          Get the data type of this rate matrix
 void getTransitionProbabilities(double[][] probabilityStore)
          A utility method for speed, transfers trans prob information quickly into store
 double getTransitionProbability(int fromState, int toState)
           
 void rebuild()
           
protected abstract  void rebuildRateMatrix(double[][] rate, double[] parameters)
           
 void scale(double scale)
           
 void setDistance(double distance)
          Sets the distance (such as time/branch length) used when calculating the probabilities.
 void setDistanceTranspose(double distance)
          Sets the distance (such as time/branch length) used when calculating the probabilities.
protected  void setFrequencies(double[] f)
           
 double setParametersNoScale(double[] parameters)
           
protected  void setSequenceType(SequenceType dt)
           
protected  void updateMatrixExp()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jebl.evolution.substmodel.RateMatrix
getUniqueName
 

Constructor Detail

AbstractRateMatrix

protected AbstractRateMatrix(int dim)
Method Detail

getDimension

public int getDimension()
Specified by:
getDimension in interface RateMatrix
Returns:
the dimension of this rate matrix.

getEquilibriumFrequencies

public double[] getEquilibriumFrequencies()
Specified by:
getEquilibriumFrequencies in interface RateMatrix
Returns:
stationary frequencies (sum = 1.0)

getEquilibriumFrequency

public double getEquilibriumFrequency(int i)
Specified by:
getEquilibriumFrequency in interface RateMatrix
Returns:
stationary frequencie (sum = 1.0) for ith state

getSequenceType

public SequenceType getSequenceType()
Description copied from interface: RateMatrix
Get the data type of this rate matrix

Specified by:
getSequenceType in interface RateMatrix

setSequenceType

protected final void setSequenceType(SequenceType dt)

getRelativeRates

public double[][] getRelativeRates()
Specified by:
getRelativeRates in interface RateMatrix
Returns:
rate matrix (transition: from 1st index to 2nd index)

getTransitionProbability

public double getTransitionProbability(int fromState,
                                       int toState)
Specified by:
getTransitionProbability in interface RateMatrix
Parameters:
fromState - The state from which we are starting
toState - The resulting state
Returns:
the probability of going from one state to another given the current distance

rebuild

public final void rebuild()

setDistance

public final void setDistance(double distance)
Sets the distance (such as time/branch length) used when calculating the probabilities.

Specified by:
setDistance in interface RateMatrix

setDistanceTranspose

public final void setDistanceTranspose(double distance)
Sets the distance (such as time/branch length) used when calculating the probabilities. The resulting transition probabilities will be in reverse (that is in the matrix instead of [from][to] it's [to][from])


getTransitionProbabilities

public final void getTransitionProbabilities(double[][] probabilityStore)
A utility method for speed, transfers trans prob information quickly into store

Specified by:
getTransitionProbabilities in interface RateMatrix

scale

public void scale(double scale)

setFrequencies

protected void setFrequencies(double[] f)

setParametersNoScale

public double setParametersNoScale(double[] parameters)

rebuildRateMatrix

protected abstract void rebuildRateMatrix(double[][] rate,
                                          double[] parameters)

updateMatrixExp

protected void updateMatrixExp()

getFrequencies

protected final double[] getFrequencies()