Table of Contents

Class: ScaledDPAlgorithms Bio/HMM/DynamicProgramming.py

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 straightfoward then log transformation but may still give underflow errors for some types of models. In these cases, the LogDPAlgorithms class should be used.

Base Classes   
AbstractDPAlgorithms
Methods   
__init__
_backward_recursion
_calculate_s_value
_forward_recursion
  __init__ 
__init__ (
        self,
        markov_model,
        sequence,
        )

Initialize the scaled approach to calculating probabilities. Arguments:

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

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

  _backward_recursion 
_backward_recursion (
        self,
        cur_state,
        sequence_pos,
        backward_vars,
        )

Calculate the value of the backward recursion

Arguments:

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

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

  • backward_vars -- The current set of backward variables

  _calculate_s_value 
_calculate_s_value (
        self,
        seq_pos,
        previous_vars,
        )

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:

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

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

Returns:

  • The calculated scaling variable for the sequence item.

  _forward_recursion 
_forward_recursion (
        self,
        cur_state,
        sequence_pos,
        forward_vars,
        )

Calculate the value of the forward recursion.

Arguments:

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

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

  • forward_vars -- The current set of forward variables


Table of Contents

This document was automatically generated on Mon Jul 1 12:03:09 2002 by HappyDoc version 2.0.1