code: def forward_algo(self,observations):
          
  
          # Store total number of observations total_stages = len(observations) 
          total_stages = len(observations)
  
          # Alpha[i] stores the probability of reaching state 'i' in stage 'j' where 'j' is the iteration number
  
          # Inittialize Alpha
          ob_ind = self.obs_map[ observations[0] ]
          alpha = np.multiply ( np.transpose(self.em_prob[:,ob_ind]) , self.start_prob )
  
          # Iteratively find alpha(using knowledge of alpha in the previous stage)
          for curr_t in range(1,total_stages):
              ob_ind = self.obs_map[observations[curr_t]]
              alpha = np.dot( alpha , self.trans_prob)
              alpha = np.multiply( alpha , np.transpose( self.em_prob[:,ob_ind] ))
  
          # Sum the alpha's over the last stage
          total_prob = alpha.sum()
          return ( total_prob )
docs: Finds the probability of an observation sequence for given model parameters
  
          **Arguments**:
  
          :param observations: The observation sequence, where each element belongs to 'observations' variable declared with __init__ object. 
          :type observations: A list or tuple
  
          :return: The probability of occurence of the observation sequence
          :rtype: float 
  
          **Example**:
  
          >>> states = ('s', 't')
          >>> possible_observation = ('A','B' )
          >>> # Numpy arrays of the data
          >>> start_probability = np.matrix( '0.5 0.5 ')
          >>> transition_probability = np.matrix('0.6 0.4 ;  0.3 0.7 ')
          >>> emission_probability = np.matrix( '0.3 0.7 ; 0.4 0.6 ' )
          >>> # Initialize class object
          >>> test = hmm(states,possible_observation,start_probability,transition_probability,emission_probability)
          >>> observations = ('A', 'B','B','A')
          >>> print(test.forward_algo(observations))
  
          .. note::
              No scaling applied here and hence this routine is susceptible to underflow errors. Use :func:`hmm.log_prob` instead.