我在mapreduce hadoop中实现HMM,但是在双下溢之后,bwd的以下部分值变为零
bwd = new double[numofstates][T];
/* initialization (time 0) */
for (int i = 0; i < numofstates; i++)
bwd[i][T-1] = 1;
/* induction */
double dtemp ;
for (int t = T - 2; t >= 0; t--) {
for (int i = 0; i < numofstates; i++) {
bwd[i][t] = 0;
for (int j = 0; j < numofstates; j++){
dtemp = (bwd[j][t+1] * A[i][j] * B[j][o[t+1]]);
if(Double.compare(dtemp, 0.0) < 0)
{
//to check
context.write(new Text("t " + t) , new Text("negative"));
}
else
bwd[i][t] =bwd[i][t] + dtemp;
//to check
context.write(new Text("t "+t + " i "+i + "j "+j),new Text("temp" + dtemp + " " + bwd[i][t]));
}
}
}
这是输出:
t 108 i 3j 1 temp2.5E-5 5.0E-5
t 108 i 3j 3 temp2.5E-5 1.775E-4
.
.
t 20 i 3 j 2 temp 0.0 0.0
t 21 i 0j 0 temp4.9E-324 4.9E-324
t 21 i 0j 2 temp2.5E-323 3.5E-323
现在t到21之后bwd [0] [20]也变成“零”,即使这是一个补充。我无法理解那里发生了什么。