The moment generating function ofXis the function oftgiven by the expectation of . Expanded as a power series int, the coefficient of is where is ther-th moment.

So the expectation ofX, which is , is the coefficient oftin or alternatively .

To recoverXwe see that the random variable which takes values 1, 2, 3 with probabilities 1/6, 1/3, 1/2 respectively has the required MGF.

There's a good article in MathWorld.