https://cs.nyu.edu/faculty/davise/ai/bayesText.htmlhtml
public void normalize() { // // 拉普拉斯校訂:通常經過將全部的計數+1來進行。see: http://cs.nyu.edu/faculty/davise/ai/bayesText.html for (int r = 0; r < numberOfState; r++) { boolean gotZeroCount = false; for (int c = 0; c < numberOfState; c++) { if(table[r][c] == 0) { gotZeroCount = true; break; } } if (gotZeroCount) { for (int c = 0; c < numberOfState; c++) { table[r][c] += 1; } } } // normalize for (int r = 0; r < numberOfState; r++) { double rowSum = getRowSum(r); for (int c = 0; c < numberOfState; c++) { table[r][c] = table[r][c] / rowSum; } } }