AI Wiki中文/EN

Vector spaces

向量空间

Why do some numerical sets allow arbitrary linear combinations while others do not? Understand closure through balance constraints and probabilities.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Does adding valid data produce valid data?

Two three-dimensional vectors fit the same array type but may belong to sets permitting different operations. If coordinates represent net balances required to sum to zero, adding two balanced accounts preserves the constraint. If they represent three class probabilities, each distribution sums to 1, but adding two distributions gives total mass 2.

This is a question of closure, not array shape. A vector space permits addition and arbitrary scalar scaling without leaving the space. Probability distributions can be represented by real vectors, but the set of valid distributions is not a vector space under ordinary addition.

Specifying the permitted operations helps determine whether dimension reduction, superposition, or optimization violates a model’s constraints. Bounded image pixels likewise do not make the set of valid images closed under every real scaling.

A set, a scalar field, and operations

We use real vector spaces: nonempty sets VV equipped with vector addition and multiplication by real scalars. Addition is commutative and associative, with a zero vector and an additive inverse for every vector. Scalar multiplication obeys compatibility and distributive rules:

a(bx)=(ab)x,1x=x,a(x+y)=ax+ay,(a+b)x=ax+bx.a(bx)=(ab)x,\qquad 1x=x,\qquad a(x+y)=ax+ay,\qquad (a+b)x=ax+bx.

Operations must return elements of VV. Saying that VV contains arrays does not fully define the space; the scalar field and operations also matter. Matrices, polynomials with a fixed upper degree bound, and suitable sets of functions can form vector spaces under their respective addition and scaling operations. MML, Section 2.4

For a subset UU of an existing vector space VV using the inherited operations, the subspace test is simpler: UU is nonempty and closed under arbitrary linear combinations. For the following set, the closure argument fits in one line:

U={x∈R3:x1+x2+x3=0},∑i(axi+byi)=a∑ixi+b∑iyi=0.U=\{x\in\mathbb R^3:x_1+x_2+x_3=0\},\qquad \sum_i(ax_i+by_i)=a\sum_i x_i+b\sum_i y_i=0.

The zero vector belongs to UU, so it is a subspace. It is not the entire three-dimensional ambient space: one constraint restricts the coordinates to a plane through the origin. Formal dimension calculations come in the article on bases and rank.

The span of vectors v1,…,vkv_1,\ldots,v_k is the set of all their linear combinations:

span⁡(v1,…,vk)={∑i=1kaivi:ai∈R}.\operatorname{span}(v_1,\ldots,v_k)=\left\{\sum_{i=1}^{k}a_i v_i:a_i\in\mathbb R\right\}.

Adding two combinations or multiplying one by a scalar produces another combination of the same generators, so a span is always a subspace. It can be smaller than the ambient space, and its generating vectors can be redundant. Deep Learning, Section 2.4

Use code for counterexamples and algebra for proofs

This complete example contrasts zero-sum and probability constraints. Integers and exact fractions keep floating-point tolerances separate from the definitions.

from fractions import Fraction as F

def combine(a, x, b, y):
    if len(x) != len(y):
        raise ValueError("dimension mismatch")
    return tuple(a * u + b * v for u, v in zip(x, y))

def zero_sum(x):
    return sum(x) == 0

def probability_vector(x):
    return all(v >= 0 for v in x) and sum(x) == 1

u, v = (1, -1, 0), (0, 2, -2)
assert zero_sum(u) and zero_sum(v)
assert combine(2, u, -3, v) == (2, -8, 6)
assert zero_sum(combine(2, u, -3, v))
p, q = (1, 0, 0), (0, 1, 0)
assert probability_vector(p) and probability_vector(q)
assert not probability_vector(combine(1, p, 1, q))
assert probability_vector(combine(F(1, 2), p, F(1, 2), q))

A combination or constraint check requires O(d)O(d) coordinate operations, with O(d)O(d) output allocation for a combination. Exact-fraction bit costs additionally depend on numerator and denominator lengths. A test can find a counterexample to closure; passing finitely many inputs cannot prove a claim about every vector and coefficient.

Subspaces, affine sets, and convex sets

Changing the constraint to x1+x2+x3=1x_1+x_2+x_3=1 gives a plane missing the zero vector, so it is not a linear subspace. It is a translated subspace, an affine set. Adding nonnegativity gives the probability simplex, which is closed under combinations with nonnegative coefficients summing to 1 and is convex.

These three kinds of sets should not be conflated. Averaging probability vectors preserves a valid distribution, while subtracting one distribution or multiplying it by 3 generally does not. Projections and constraints in optimization address this distinction.

Exact constraints also differ from noisy observations. Three measured values summing almost to zero do not establish an exact zero-sum law. An approximate subspace model should report deviations, noise scales, and fitting error.

What can one counterexample establish?

  1. Do all nonnegative two-dimensional vectors form a real vector space? Answer: no. Multiplying (1,0)(1,0) by -1 leaves the set.
  2. Do real polynomials of degree at most 2 form a space under ordinary operations? Answer: yes, including the zero polynomial. Polynomials of exactly degree 2 are not closed because leading terms can cancel.
  3. Is the intersection of two subspaces a subspace? Answer: yes. Both contain zero, and a linear combination remains in both.
  4. Is their union necessarily a subspace? Answer: no. The union of the horizontal and vertical axes does not contain (1,0)+(0,1)=(1,1)(1,0)+(0,1)=(1,1).

Allowed combinations become modeling assumptions

Principal component analysis seeks a low-dimensional subspace, and linear regression restricts predictions to a design matrix’s column space. Constrained optimization handles the probability simplex, nonnegative sets, and other regions that do not permit arbitrary linear combinations. Establish the set in which a model operates before discussing distance, direction, and optimality. Convenient array operations do not determine a problem’s mathematical structure.

Make a prediction, then check

Do nonnegative probability vectors summing to one form a vector space under usual addition and scaling?

Choose one answer

Learning objectives

  • Check a subspace using the zero vector and closure under addition and scaling.
  • Distinguish vector spaces, spans, and probability sets with nonnegativity constraints.

Prerequisites & connections

Explore related knowledge →

References

  1. Mathematics for Machine Learning — mathematical foundations (2024-01-15 draft)
    Marc Peter Deisenroth; A. Aldo Faisal; Cheng Soon Ong · 2020
  2. Deep Learning — Chapter 2: Linear Algebra
    Ian Goodfellow; Yoshua Bengio; Aaron Courville · 2016

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-05 · Codex technical check: cited-source comparison, re-derivation and recalculation, bilingual argument comparison, and executed Python assertions; no independent human peer review.

  • Checked real-space axioms and nonempty linear-combination closure; recalculated zero-sum combinations and probability counterexamples.
  • Checked inclusion of the zero polynomial, subspace intersection, and the union-of-axes counterexample; distinguished affine sets and the probability simplex.
  • Compared arguments, numbers, examples, limitations, and exercise answers across languages; structural validation separately compares display formulas, code, sources, and sections. No independent human peer review.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.