emissionProbabilityMatrix.setRowVector(rowIndex,
DenseDoubleVector.ones(numVisibleStates));
}
for (int i = 0; i < features.length; i++) {
DoubleVector feat = features[i];
DoubleVector out = outcome[i];
int index = getOutcomeState(out);
hiddenPriorProbability.set(index, hiddenPriorProbability.get(index) + 1);
// count the emissions from feature layer to the hidden layer
Iterator<DoubleVectorElement> iterateNonZero = feat.iterateNonZero();
while (iterateNonZero.hasNext()) {
DoubleVectorElement next = iterateNonZero.next();
emissionProbabilityMatrix.set(index, next.getIndex(),
emissionProbabilityMatrix.get(index, next.getIndex()) + 1);
}
// now handle the feature by counting the transitions between the hidden
// states with the next feature
if (i + 1 < features.length) {
DoubleVector nextOut = outcome[i + 1];
int nextIndex = getOutcomeState(nextOut);
transitionProbabilityMatrix.set(index, nextIndex,
transitionProbabilityMatrix.get(index, nextIndex) + 1);
}
}