private void backward ( int [ ] o , double [ ] [ ] beta , double [ ] scaling ) { int n = o . length - 1 ; for ( int i = 0 ; i < numStates ; i ++ ) { beta [ n ] [ i ] = 1.0 / scaling [ n ] ; } for ( int t = n ; t -- > 0 ; ) { for ( int i = 0 ; i < numStates ; i ++ ) { double sum = 0. ; for ( int j = 0 ; j < numStates ( ) ; j ++ ) { sum += beta [ t + 1 ] [ j ] * a [ i ] [ j ] * b [ j ] [ o [ t + 1 ] ] ; } beta [ t ] [ i ] = sum / scaling [ t ] ; } } }
Scaled backward procedure without underflow .