# Indicator function

In mathematics, an indicator function or a characteristic function of a subset of a set is a function that maps elements of the subset to one, and all other elements to zero. That is, if A is a subset of some set X, then $\ \mathbf {1} _{A}\!(x)\equiv 1\$ if $\ x\in A\ ,$ and $\ \mathbf {1} _{A}\!(x)\equiv 0\$ otherwise, where $\ \mathbf {1} _{A}\$ is one common notation for the indicator function; other common notations are $\ I_{A}\!(x)\ ,$ $\ \chi _{A}\!(x)\ ,$ and $\ \operatorname {\mathbb {I} } \!{\bigl\ x\in A\ {\bigr )}~.$
The indicator function of A is the Iverson bracket of the property of belonging to A; that is,
$\ \mathbf {1} _{A}(x)=\left[\ x\in A\ \right]~.$
For example, the Dirichlet function is the indicator function of the rational numbers as a subset of the real numbers.

## Definition

Given an arbitrary set X, an indicator function of a subset A for X is defined by the function (::)
$\ \mathbf {1} _{A}\colon X\mapsto \{0,1\}\$
or, more specifically by (::)
$\operatorname {\mathbf {1} } _{A}\!(x)\equiv {\begin{cases}1\quad &{\mathsf {if}}\quad x\in A\ ,\\0\quad &{\mathsf {if}}\quad x\notin A~.\end{cases}}$
The Iverson bracket provides the equivalent notation, $\ \left[\ x\in A\ \right]\$ or ⟦ x ∈ A ⟧ , that can be used instead of $\ \mathbf {1} _{A}\!(x)~.$
The function $\ \mathbf {1} _{A}\$ is sometimes denoted I$_A$, χ$_A$, K$_A$, or even just A.

## Notation and terminology

The notation $\ \chi _{A}\$ is also used to denote the characteristic function in convex analysis, which is defined as if using the reciprocal of the standard definition of the indicator function.
A related concept in statistics is that of a dummy variable. (This must not be confused with "dummy variables" as that term is usually used in mathematics, also called a bound variable.)
The term "characteristic function" has an unrelated meaning in classic probability theory. For this reason, traditional probabilists use the term indicator function for the function defined here almost exclusively, while mathematicians in other fields are more likely to use the term characteristic function to describe the function that indicates membership in a set.
In fuzzy logic and modern many-valued logic, predicates are the characteristic functions of a probability distribution. That is, the strict true/false valuation of the predicate is replaced by a quantity interpreted as the degree of truth.

## Basic properties

The indicator or characteristic function of a subset A of some set X maps elements of X to the codomain $\ {\bigl \\ 0,1\ {\bigr \}}~.$
This mapping is surjective only when A is a non-empty proper subset of   X . 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{aligned}\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{aligned}}$
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 X. For any $\ x\in X\ :$
$\prod _{k\in I}\left(\ 1-\mathbf {1} _{A_{k}}\!\left(x\right)\ \right)\$
is clearly a product of 0s and 1s. This product has the value 1 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)^{|F|}\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 F. 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 X is a probability space with probability measure $\ \operatorname {\mathbb {P} } \$ and A is a measurable set, then $\ \mathbf {1} _{A}\$ becomes a random variable whose expected value is equal to the probability of A:
$\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

Given a probability space $\textstyle (\Omega ,{\mathcal {F}},\operatorname {P} )$ with $A\in {\mathcal {F}},$ the indicator random variable $\mathbf {1} _{A}\colon \Omega \rightarrow \mathbb {R}$ is defined by $\mathbf {1} _{A}(\omega )=1$ if $\omega \in A,$ otherwise $\mathbf {1} _{A}(\omega )=0.$

### Mean

    $\ \operatorname {\mathbb {E} } (\mathbf {1} _{A}(\omega ))=\operatorname {\mathbb {P} } (A)\$ (also called "Fundamental Bridge").

### Variance

    $\ \operatorname {Var} (\mathbf {1} _{A}(\omega ))=\operatorname {\mathbb {P} } (A)(1-\operatorname {\mathbb {P} } (A))~.$

### Covariance

    $\ \operatorname {Cov} (\mathbf {1} _{A}(\omega ),\mathbf {1} _{B}(\omega ))=\operatorname {\mathbb {P} } (A\cap B)-\operatorname {\mathbb {P} } (A)\operatorname {\mathbb {P} } (B)~.$

## Characteristic function in recursion theory, Gödel's and Kleene's representing function

Kurt Gödel described the representing function in his 1934 paper "On undecidable propositions of formal mathematical systems" (the symbol "¬" indicates logical inversion, i.e. "NOT"):$^{:42}$
   There shall correspond to each class or relation R a representing function $\ \phi (x_{1},\ldots x_{n})=0\$ if $\ R(x_{1},\ldots x_{n})\$ and $\ \phi (x_{1},\ldots x_{n})=1\$ if $\ \neg R(x_{1},\ldots x_{n})~.$
Kleene offers up the same definition in the context of the primitive recursive functions as a function φ of a predicate P takes on values 0 if the predicate is true and 1 if the predicate is false.
For example, because the product of characteristic functions $\ \phi _{1}*\phi _{2}*\cdots *\phi _{n}=0\$ whenever any one of the functions equals 0, it plays the role of logical OR: IF $\ \phi _{1}=0\$ OR $\ \phi _{2}=0\$ OR ... OR $\ \phi _{n}=0\$ THEN their product is 0. What appears to the modern reader as the representing function's logical inversion, i.e. the representing function is 0 when the function R is "true" or satisfied", plays a useful role in Kleene's definition of the logical functions OR, AND, and IMPLY,$^{:228}$ the bounded-$^{:228}$ and unbounded-$^{:279ff}$ mu operators and the CASE function.$^{:229}$

## Characteristic function in fuzzy set theory

In classical mathematics, characteristic functions of sets only take values 1 (members) or 0 (non-members). In fuzzy set theory, characteristic functions are generalized to take value in the real unit interval [0, 1], or more generally, in some algebra or structure (usually required to be at least a poset or lattice). Such generalized characteristic functions are more usually called membership functions, and the corresponding "sets" are called fuzzy sets. Fuzzy sets model the gradual change in the membership degree seen in many real-world predicates like "tall", "warm", etc.

## Smoothness

In general, the indicator function of a set is not smooth; it is continuous if and only if its support is a connected component. In the algebraic geometry of finite fields, however, every affine variety admits a (Zariski) continuous indicator function. Given a finite set of functions $\ f_{\alpha }\in \mathbb {F} _{q}\left[\ x_{1},\ldots ,x_{n}\ \right]\$ let $\ V={\bigl \\ x\in \mathbb {F} _{q}^{n}:f_{\alpha }(x)=0\ {\bigr \}}\$ be their vanishing locus. Then, the function P(x)=∏( 1−f$_α$(x)$^{q−1}$ ) {\textstyle \ \mathbb {P} (x)=\prod \left(\ 1-f_{\alpha }(x)^{q-1}\ \right)\ } acts as an indicator function for $\ V~.$ If $\ x\in V\$ then $\ \mathbb {P} (x)=1\ ,$ otherwise, for some $\ f_{\alpha }\ ,$ we have $\ f_{\alpha }(x)\neq 0\$ which implies that $\ f_{\alpha }(x)^{q-1}=1\ ,$ hence $\ \mathbb {P} (x)=0~.$
Although indicator functions are not smooth, they admit weak derivatives. For example, consider Heaviside step function $\ H(x)\equiv \operatorname {\mathbb {I} } \!{\bigl\ x>0\ {\bigr )}\$ The distributional derivative of the Heaviside step function is equal to the Dirac delta function, i.e. ${\frac {\ \mathrm {d} \ H(x)\ }{\ \mathrm {d} \ x\ }}=\delta (x)\$ and similarly the distributional derivative of $\ G(x):=\operatorname {\mathbb {I} } \!{\bigl\ x<0\ {\bigr )}\$ is $\ {\frac {\ \mathrm {d} \ G(x)\ }{\ \mathrm {d} \ x\ }}=-\delta (x)~.$
Thus the derivative of the Heaviside step function can be seen as the inward normal derivative at the boundary of the domain given by the positive half-line. In higher dimensions, the derivative naturally generalises to the inward normal derivative, while the Heaviside step function naturally generalises to the indicator function of some domain D. The surface of D will be denoted by S. Proceeding, it can be derived that the inward normal derivative of the indicator gives rise to a surface delta function, which can be indicated by $\ \delta _{S}(\mathbf {x} )\$: $\delta _{S}(\mathbf {x} )=-\mathbf {n} _{x}\cdot \nabla _{x}\operatorname {\mathbb {I} } \!{\bigl\ \mathbf {x} \in D\ {\bigr )}\$ where n is the outward normal of the surface S. This 'surface delta function' has the following property: $-\int _{\mathbb {R} ^{n}}f(\mathbf {x} )\,\mathbf {n} _{x}\cdot \nabla _{x}\operatorname {\mathbb {I} } \!{\bigl\ \mathbf {x} \in D\ {\bigr )}\;\operatorname {d} ^{n}\mathbf {x} =\oint _{S}\,f(\mathbf {\beta } )\;\operatorname {d} ^{n-1}\mathbf {\beta } \ .$
By setting the function f equal to one, it follows that the inward normal derivative of the indicator integrates to the numerical value of the surface area S.