The random variable 1A takes the value 1 if ω∈A and 0 otherwise.
E[1A]=P(A)
Indicator functions are very useful for computations as the next example will show.
Example 1.
Consider the hat problem we solved using the inclusion exclusion principle.
Let X be the random variable, the number of people who get back their own hat.
X=1A1+1A2+…+1An
We can calculate the mean and variance of X using linearity of the expectation operator.
E[X]=n∑iE[1Ai]=n∑i=1P(Ai)=1
X2=n∑i12Ai+2∑i<j1Ai1Aj
so that
E[X2]=n∑iP(Ai)+2∑i<jP(Ai∩Aj)=1+2n(n−1)21n1n−1=2
so Var(X)=1