Fixed bug where the last posterior probability was set to 0