added a mex version that is O(K^2) instead of O(KT) by sequentially updating suff stats