The Forward Algorithm

The Forward Algorithm is an iterative algorithm used to compute the filtering distribution: p(Xt | e1:t). Note that we are computing an entire distribution.


FORWARD-ALGORITHM(X, e, t, bn)
    
    F = p(X0) // The prior distribution
    
    for time=1...t
    
        G = {} // Will hold the updated distribution
        
        // Remember, we need to compute the distribution over Xt
        for p in domain of Xt

            sum = 0
            for q in domain of Xt-1
                sum += p(Xt = p | Xt-1 = q) * F(q)
            end

            G(p) = p(et | Xt = p) * sum
        end

	F = G // Update the distribution 
    end    

    return F
end