probml / pmtk3

Probabilistic Modeling Toolkit for Matlab/Octave.
MIT License
1.55k stars 797 forks source link

fixes issue computing the tabular CPD #129

Closed flokadillo closed 7 years ago

flokadillo commented 7 years ago

There are three issues with condDiscreteProdCpdFit:

  1. the tabular cpd T is computed but not returned.

  2. as far as I understand, alpha should not be added to the observations but rather to the counts.

  3. histc should specify the dimension over which it operates. Otherwise, it doesn't work if Y(Z==k, :) has only one row.

This can be tested with the following code:

states{1} = [1, 1, 1, 2, 2, 3, 1];   
observations{1} = [1, 1, 1, 2, 2, 3, 1];  
model = hmmFitFullyObs(states, observations, 'discrete');  
decodedFromTrueViterbi = hmmMap(model, observations{1});  
assert(isequal(decodedFromTrueViterbi, states{1}));