In mathematics, the indicator function (sometimes also called characteristic function) of a subset A of a set X is a function from A into to {0,1} defined as follows:

The term characteristic function is potentially confusing becase it is also used to denote a quite different concept that is also prevalent in probability theory; see characteristic function.

The indicator function is a basic tool in probability theory: if X is a probability space with probability measure P and A is a measurable set, then IA becomes a random variable whose expected value is equal to the probability of A:

For discrete spaces the proof may be written more simply as

Furthermore, if A and B are two subsets of X, then