Completed the Code

added the expected count calculator, the probabilities re-estimator.
Still some bugs are remained to be fixed. The outside calculation
doesn't seem to be correct.