AI Glossary / Data science and analytics / Advanced
Binary variable
Definition
A binary variable has two possible substantive values, often represented as 0 and 1 or as two category labels. Examples include completed or not completed, available or unavailable, and accepted or rejected. Its meaning comes from the rule defining those two states, not from the symbols used to store them. Missing information is distinct from either substantive state.
What it means
Binary variables simplify observations into a two-way distinction. They can represent an outcome, a characteristic or whether a condition holds. Coding an article as reviewed or not reviewed, for example, supports counting and filtering, but does not capture the review's quality or the number of corrections needed.
The definition must specify the observation unit and timing. “Completed” could mean finishing an exercise during one session, within a week or at any point. Those are different variables even if every file uses the same 0 and 1 codes. Document these distinctions in a data dictionary.
How it works
Define two mutually exclusive states covering the intended observed outcome. Assign labels or codes consistently and validate incoming records against that definition. When using a 0/1 indicator, its sum counts observations coded 1, and its arithmetic mean gives their proportion among the observations included in that calculation.
Keep missing, unknown and not-applicable states identifiable. A storage system may allow null values alongside a binary field without making null a third substantive outcome. If uncertainty is itself an outcome of interest, the intended variable may require more than two categories.
A binary random variable can be modeled with a Bernoulli distribution. That mathematical description does not establish that multiple observations are independent or share the same probability; those assumptions depend on the observation process.
Three practical examples
- A glossary tracker records whether each article has passed a defined reference check. The team preserves the check date and version so that a 1 does not imply that every future revision is also checked.
- A website records whether an eligible reader completes an exercise within seven days. Unknown tracking results remain separate from confirmed non-completions, and the rate uses a documented denominator.
- An inventory system records whether an item is available for sale. The field supports filtering; a separate stock quantity records how many units can be supplied.
Think of it this way
A binary variable resembles a two-choice tick box accompanied by a precise question. The tick depends on the question. If one person reads “reviewed” as “opened by an editor” and another reads it as “approved for publication,” identical ticks describe different states. The definition is part of the data.
Worked example
Suppose ten fictional articles are checked for a broken link. Define 1 as at least one broken link found and 0 as no broken link found under the stated check. Eight results are known: [1, 0, 0, 1, 0, 0, 0, 1]. Two articles have not yet been checked.
The sum of the observed indicators is 3. The observed proportion is 3 / 8 = 37.5%. Replacing the two unknowns with 0 would produce 3 / 10 = 30%, incorrectly treating unchecked articles as checked and clear.
Across all ten articles, the eventual proportion could range from 3 / 10 = 30% to 5 / 10 = 50%, depending on the two pending results. This is a simple completion range, not a statistical confidence interval. Also, the indicator counts affected articles: it does not count individual broken links, since one article may contain several.
Illustrative case study
In a fictional project, Willow Archive combines editorial spreadsheets from several teams. Every sheet contains a field called “approved,” but one team uses 1 for content approval and another uses 1 for layout approval. A combined completion figure therefore mixes two different decisions.
The coordinator replaces the ambiguous field with separately defined content-approved and layout-approved indicators. Unknown results remain pending, and publication readiness requires both approvals for the relevant article version. The team records who made each decision and when, rather than expecting two bits to preserve the whole review history.
The revised data supports a more reliable readiness report. It does not make approval objective or permanent: the underlying review criteria and version changes still matter. This fictional case illustrates clearer binary definitions.
Common misconceptions and mistakes
Binary does not mean the two values are equally likely. It also does not imply that the underlying phenomenon naturally has only two states. Turning a continuous score into pass or fail creates a thresholded variable and discards information about distance from the threshold.
The codes need not be 0 and 1, but arithmetic depends on the coding. Averaging labels stored as 1 and 2 does not directly give the proportion in the second category. Preserve the mapping when importing or exporting data.
Do not confuse a binary observed outcome with a predicted probability. A predicted value of 0.8 expresses a model estimate; it is not an observed outcome partly equal to 1.
Business use
Binary variables are useful for operational checks, experiment outcomes, eligibility rules and model features. Define them carefully enough that different teams can produce the same value from the same evidence.
Report counts and denominators alongside rates, especially when observations are missing or eligibility varies. Retain richer measurements when a two-way summary would hide useful distinctions. For machine learning, check whether a field becomes known only after the outcome being predicted; such a field may leak future information even though its format is simple.
People also ask
Is a binary variable categorical?
It can be treated as a two-category variable, even when its labels are numeric.
Can a binary field contain missing values?
Many systems allow that, but missingness needs explicit handling and should not silently map to 0.
Is a Boolean identical?
Boolean is a logical true/false type; a binary variable is a broader statistical description that may use other labels or encodings.
Check your understanding
Why is 30% misleading as the observed checked-article rate?
Answer: It includes unchecked articles in the denominator as though their outcomes were known.
What does the sum of a 0/1 indicator count?
Answer: The number of included observations coded 1.
Does a binary outcome imply a common probability across people?
Answer: No. Probabilities may differ with context or characteristics.
Related terms
- Boolean
- Categorical variable
- Binary classification
- Missing data
- Threshold (for decision trees)
- Indicator variable
- Bernoulli distribution
- denominator
- threshold
- data dictionary
Learn next
Write a precise definition for a yes/no field, including timing and unknown outcomes. Then calculate its count and proportion from a small dataset and check that the denominator matches the stated question.
More in Data science and analytics
- Bar chart - A bar chart displays values using rectangular bars whose lengths represent magnitude on a shared numerical scale.
- Base effect - A base effect is the influence of the comparison period's value on a reported rate of change.
- Bernoulli trial - A Bernoulli trial is a random experiment whose recorded outcome has two possibilities, conventionally called success and failure.
- Box plot - A box plot summarizes the distribution of numerical data using a median, quartiles and whiskers.
- Causal analysis - Causal analysis investigates whether and how changing one factor would change an outcome.
- Cherry-Picking - Cherry-picking is the selective use or presentation of evidence that favors a desired conclusion while leaving out relevant evidence that would weaken...
Sources
Frank Harrell, Glossary of Statistical Terms, binary variable: supplied statistical definition. https://hbiostat.org/glossary/ OpenStax, Statistics, Binomial Distribution: binary trial outcomes and the additional conditions for repeated-trial models. https://openstax.org/books/statistics/pages/4-3-binomial-distribution-optional The article-check calculations and Willow Archive case are original illustrations, not empirical results or claims about the current project log.
Previous: Binary search Next: Binding list