Package Bio :: Package HMM :: Module DynamicProgramming :: Class ScaledDPAlgorithms
[hide private]
[frames] | no frames]

Class ScaledDPAlgorithms

source code

          object --+    
                   |    
AbstractDPAlgorithms --+
                       |
                      ScaledDPAlgorithms

Implement forward and backward algorithms using a rescaling approach.

This scales the f and b variables, so that they remain within a
manageable numerical interval during calculations. This approach is
described in Durbin et al. on p 78.

This approach is a little more straightforward then log transformation
but may still give underflow errors for some types of models. In these
cases, the LogDPAlgorithms class should be used.

Instance Methods [hide private]
 
__init__(self, markov_model, sequence)
Initialize the scaled approach to calculating probabilities.
source code
 
_calculate_s_value(self, seq_pos, previous_vars)
Calculate the next scaling variable for a sequence position.
source code
 
_forward_recursion(self, cur_state, sequence_pos, forward_vars)
Calculate the value of the forward recursion.
source code
 
_backward_recursion(self, cur_state, sequence_pos, backward_vars)
Calculate the value of the backward recursion
source code

Inherited from AbstractDPAlgorithms: backward_algorithm, forward_algorithm

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, markov_model, sequence)
(Constructor)

source code 
Initialize the scaled approach to calculating probabilities.
Arguments:

o markov_model -- The current Markov model we are working with.

o sequence -- A TrainingSequence object that must have a
set of emissions to work with.

Overrides: object.__init__

_calculate_s_value(self, seq_pos, previous_vars)

source code 
Calculate the next scaling variable for a sequence position.

This utilizes the approach of choosing s values such that the
sum of all of the scaled f values is equal to 1.

Arguments:

o seq_pos -- The current position we are at in the sequence.

o previous_vars -- All of the forward or backward variables
calculated so far.

Returns:

o The calculated scaling variable for the sequence item.

_forward_recursion(self, cur_state, sequence_pos, forward_vars)

source code 
Calculate the value of the forward recursion.

Arguments:

o cur_state -- The letter of the state we are calculating the
forward variable for.

o sequence_pos -- The position we are at in the training seq.

o forward_vars -- The current set of forward variables

Overrides: AbstractDPAlgorithms._forward_recursion

_backward_recursion(self, cur_state, sequence_pos, backward_vars)

source code 
Calculate the value of the backward recursion

Arguments:

o cur_state -- The letter of the state we are calculating the
forward variable for.

o sequence_pos -- The position we are at in the training seq.

o backward_vars -- The current set of backward variables

Overrides: AbstractDPAlgorithms._backward_recursion