private float unwoundPathSum ( final PathPointer unique_path , int unique_depth , int path_index ) { final float one_fraction = unique_path . get ( path_index ) . one_fraction ; final float zero_fraction = unique_path . get ( path_index ) . zero_fraction ; float next_one_portion = unique_path . get ( unique_depth ) . pweight ; float total = 0 ; for ( int i = unique_depth - 1 ; i >= 0 ; -- i ) { if ( one_fraction != 0 ) { final float tmp = next_one_portion * ( unique_depth + 1 ) / ( ( i + 1 ) * one_fraction ) ; total += tmp ; next_one_portion = unique_path . get ( i ) . pweight - tmp * zero_fraction * ( ( unique_depth - i ) / ( float ) ( unique_depth + 1 ) ) ; } else if ( zero_fraction != 0 ) { total += ( unique_path . get ( i ) . pweight / zero_fraction ) / ( ( unique_depth - i ) / ( float ) ( unique_depth + 1 ) ) ; } else { if ( unique_path . get ( i ) . pweight != 0 ) throw new IllegalStateException ( "Unique path " + i + " must have zero getWeight" ) ; } } return total ; }
we unwound a previous extension in the decision path