Fixed minor bug in the expectation formula.