# Discrete Random Variables - Indicator Variables

An **indicator variable** is a random variable that takes the value 1 for some desired outcome and the value 0 for all other outcomes. They indicate (hence the name) whether a subject belongs to a specific category or not. More specifically, an indicator variable $X$ is defined by

$X = \begin{cases} 1 & \text{desired event} \\ 0 & \text{other event}. \end{cases}$

## Properties of Indicator Variables

Indicator variables satisfy an important property: if $X$ and $Y$ are indicator variables, then

$XY = \begin{cases} 1 & \text{“both" desired events} \\ 0 & \text{other event}. \end{cases}$

Indicator variables can be used in several other ways as well. For instance,

$c^X = \begin{cases} c & \text{desired event} \\ 1 & \text{other event}, \end{cases}$

which is useful for constructing a multiplicative factor; for instance, $2^X(\ldots)$ doubles the result if the desired event occurs, and leaves it unchanged otherwise. Similarly,

$cX = \begin{cases} c & \text{desired event} \\ 0 & \text{other event}, \end{cases}$

which is useful for constructing an additive factor; for instance, $cX+(\ldots)$ adds $c$ to the result if the desired event occurs, and leaves it unchanged otherwise.

## Constructing formulae with indicator variables

Indicator variables are very useful in constructing formulas involving cases since they vanish when the criteria for their case is not satisfied. Here is an example:

At a restaurant, a meal costs $10, dessert costs $5, and a drink costs $3. However, if one purchases all three, then the total price is discounted by $2. What is the price of a trip to this restaurant, in terms of the indicator variables $X_{\text{meal}}, X_{\text{dessert}}, X_{\text{drink}}?$

A patron of this restaurant would spend $10 on the meal if $X_{\text{meal}}=1$, and $0 on the meal otherwise. Hence this can be modeled by $10X_{\text{meal}}$. Similarly, the dessert and drink can be modeled by $5X_{\text{dessert}}$ and $3X_{\text{drink}}$, respectively. This gives an intermediate result of

$10X_{\text{meal}}+5X_{\text{dessert}}+3X_{\text{drink}}.$

However, this formula fails to account for the $2 discount in the case of all three being purchased. This can be expressed by an indicator variable

$X_{\text{meal}, \text{dessert}, \text{drink}} = X_{\text{meal}}X_{\text{dessert}}X_{\text{drink}},$

so the final result is

$10X_{\text{meal}}+5X_{\text{dessert}}+3X_{\text{drink}}-2X_{\text{meal}}X_{\text{dessert}}X_{\text{drink}}.\ _\square$

Indicator variables can deal with multiplicative modifiers as well:

As part of a promotion, the same restaurant decides to give 50% off the total price if a customer purchases a meal, a drink, and a dessert, instead of the flat $2 discount. Construct a formula for the new cost of a visit, using the same indicator variables.

As before, the cost without the discount can be written as

$10X_{\text{meal}}+5X_{\text{dessert}}+3X_{\text{drink}}.$

This should be halved if the customer purchases all 3 items, which can (as before) be modeled by the indicator variable $X_{\text{meal}}X_{\text{dessert}}X_{\text{drink}}$. Using the multiplicative strategy from the last section, the final result is thus

$\left(\frac{1}{2}\right)^{X_{\text{meal}}X_{\text{dessert}}X_{\text{drink}}}(10X_{\text{meal}}+5X_{\text{dessert}}+3X_{\text{drink}}).\ _\square$

## See Also

**Cite as:**Discrete Random Variables - Indicator Variables.

*Brilliant.org*. Retrieved from https://brilliant.org/wiki/discrete-random-variables-indicator-variables/