The
indicator or
characteristic function of a subset of some set
maps elements of to the
codomain \{0,\, 1\}. This mapping is
surjective only when is a non-empty
proper subset of . If A = X, then \mathbf{1}_A \equiv 1. By a similar argument, if A = \emptyset then \mathbf{1}_A \equiv 0. If A and B are two subsets of X, then \begin{align} \mathbf{1}_{A\cap B}(x) ~&=~ \min\bigl\{\mathbf{1}_A(x),\ \mathbf{1}_B(x)\bigr\} ~~=~ \mathbf{1}_A(x) \cdot\mathbf{1}_B(x), \\ \mathbf{1}_{A\cup B}(x) ~&=~ \max\bigl\{\mathbf{1}_A(x),\ \mathbf{1}_B(x)\bigr\} ~=~ \mathbf{1}_A(x) + \mathbf{1}_B(x) - \mathbf{1}_A(x) \cdot \mathbf{1}_B(x)\,, \end{align} and the indicator function of the
complement of A i.e. A^\complement is: \mathbf{1}_{A^\complement} = 1 - \mathbf{1}_A. More generally, suppose A_1, \dotsc, A_n is a collection of subsets of . For any x \in X: \prod_{k \in I} \left(\ 1 - \mathbf{1}_{A_k}\!\left( x \right)\ \right) is a product of s and s. This product has the value at precisely those x \in X that belong to none of the sets A_k and is 0 otherwise. That is \prod_{k \in I} ( 1 - \mathbf{1}_{A_k}) = \mathbf{1}_{X - \bigcup_{k} A_k} = 1 - \mathbf{1}_{\bigcup_{k} A_k}. Expanding the product on the left hand side, \mathbf{1}_{\bigcup_{k} A_k}= 1 - \sum_{F \subseteq \{1, 2, \dotsc, n\}} (-1)^ \mathbf{1}_{\bigcap_F A_k} = \sum_{\emptyset \neq F \subseteq \{1, 2, \dotsc, n\}} (-1)^{|F|+1} \mathbf{1}_{\bigcap_F A_k} where |F| is the
cardinality of . This is one form of the principle of
inclusion-exclusion. As suggested by the previous example, the indicator function is a useful notational device in
combinatorics. The notation is used in other places as well, for instance in
probability theory: if is a
probability space with probability measure \mathbb{P} and is a
measurable set, then \mathbf{1}_A becomes a
random variable whose
expected value is equal to the probability of : \operatorname\mathbb{E}_X\left\{\ \mathbf{1}_A(x)\ \right\}\ =\ \int_{X} \mathbf{1}_A( x )\ \operatorname{d\ \mathbb{P} }(x) = \int_{A} \operatorname{d\ \mathbb{P} }(x) = \operatorname\mathbb{P}(A). This identity is used in a simple proof of
Markov's inequality. In many cases, such as
order theory, the inverse of the indicator function may be defined. This is commonly called the
generalized Möbius function, as a generalization of the inverse of the indicator function in elementary
number theory, the
Möbius function. (See paragraph below about the use of the inverse in classical recursion theory.) ==Mean, variance and covariance==