The law of total expectation, also known as the law of iterated expectations (or LIE) and the “tower rule”, states that for random variables \(X\) and \(Y\),

\[\Ex(X) = \Ex\{ \Ex(X|Y) \},\]

provided that the expectations exist. A common special case involves conditioning on a partition of the sample space:

\[\Ex(X) = \sum_i \Ex(X | A_i) \Pr(A_i).\]

In this case, the law can also be written as

\[\Ex(X) = \sum_i \Ex\{ X 1(A_i) \},\]

where \(1(A_i)\) is an indicator function. This is simply the definition of expected value with the integral broken up into the partition defined by \(\{A_i\}\).