Moment Generating Function Method In Python