AI Glossary / Mathematics and optimization / Beginner

Sequence

Definition

A sequence is an ordered collection of elements indexed by positions. Elements may repeat, and changing their order can change the sequence. In mathematics, an infinite sequence is commonly defined as a function from the natural numbers to a specified set.

What it means

The sequence (2,5,2) contains three positions, including two occurrences of the value two. The set {2,5} instead records distinct members without retaining those positions or repetitions. That distinction matters whenever order carries information.

In AI, sequences can represent words, events, measurements or successive parameter values produced by an algorithm. Their elements need not be numbers: each element might be a symbol, a vector or a structured record.

A sequence is not automatically a time series. Time can supply the index, but positions can also represent an iteration counter, a character location or another ordering rule. Nor is a sequence necessarily random. A deterministic recurrence and a realization of a stochastic process are both capable of producing sequences.

How it works

Write a sequence as a₁,a₂,a₃,…, where aᵢ identifies the element at position i. Indexing can begin at zero or one, depending on convention, so equations and software should state which is used.

A sequence may be given explicitly, by a formula such as aₙ=1/n, or recursively, where a new term depends on earlier terms and initial values. A recurrence alone may not determine a unique sequence unless the starting values are specified.

A subsequence retains selected terms in their original order. It need not keep adjacent positions. By contrast, a contiguous segment keeps a consecutive block. This distinction matters when a learning task assumes that nearby positions in an input were also nearby in the source.

For numerical sequences, convergence means that eventually all later terms lie as close as desired to a limit. Some sequences converge, some grow without bound, and some oscillate indefinitely. Observing several similar terms is not a general proof of convergence, especially if the rule generating later terms is unknown.

Three practical examples

  • A language model processes a sequence of tokens whose order affects the meaning of the text.
  • An optimization study records the sequence of parameter vectors produced after successive update steps.
  • A monitoring system stores an ordered sequence of machine events, preserving repeated alarms rather than collapsing them into a set.

Think of it this way

Think of a playlist. Two playlists can contain the same songs but create different experiences because the order differs. Repeating a song also changes the playlist even though it adds no new song to the collection of distinct titles.

The analogy explains order and repetition. Mathematical sequences can be infinite and can have elements much more abstract than songs, so they are not limited by a physical playback system.

Worked example

An update sequence with an exact limit

Define a₀=0 and aₙ₊₁=(aₙ+6)/2 for n≥0. The first values are 0,3,4.5,5.25 and 5.625. Each update averages the current value with six.

Subtract six from both sides: aₙ₊₁−6=(aₙ−6)/2. Starting from a₀−6=−6 gives aₙ=6(1−2⁻ⁿ). Its distance from six is exactly 6·2⁻ⁿ, which tends to zero. The sequence therefore converges to six.

To make that distance less than 0.1, require 6·2⁻ⁿ<0.1, or 2ⁿ>60. The first qualifying integer is n=6, where a₆=5.90625 and the error is 0.09375.

The even-indexed subsequence starts 0,4.5,5.625 and has the same limit. Now compare bₙ=(−1)ⁿ: its values alternate between one and minus one, so the complete sequence does not converge, even though its even and odd subsequences each do. Sequence behavior depends on all sufficiently late positions, not just a convenient selection.

Illustrative case study

A fictional service-operations team prepares event histories for a failure-prediction experiment. A data-cleaning step converts each history into a list of unique event types, unintentionally removing repetitions and their original positions.

The analysts discover that “restart, warning, warning, stop” has become indistinguishable from histories with different ordering and frequency. They restore the sequence representation and document how events with equal timestamps are ordered.

The team also distinguishes a missing observation from a genuine period with no event. Preserving order is necessary for the intended task, but the sequence still needs clear event definitions and a consistent collection process.

Common misconceptions and mistakes

  • A sequence is just a set. Sets do not preserve the same positional information or repeated occurrences.
  • Every sequence has a limit. Oscillating sequences provide simple counterexamples.
  • Every sequence is a time series. Its index can represent something other than time.
  • A recurrence needs no initial condition. Many recurrences admit different sequences from different starts.
  • Sorting a sequence is harmless. Sorting changes positional relationships and can destroy the meaning of the original order.

Business use

Sequence awareness matters whenever AI systems learn from histories, text or iterative procedures. Before choosing a model, define what one element represents, how positions are ordered and which gaps or repetitions have meaning.

For evaluation, avoid accidentally mixing later information into earlier prediction inputs. If records come from different entities, retain their boundaries rather than concatenating unrelated histories into one apparent sequence. Document truncation, padding and sampling rules, because those choices alter the information the model receives. An ordered container is only useful when its ordering corresponds to the task.

People also ask

Can a sequence contain vectors?

Yes. An optimizer's parameter history is often a sequence whose elements are entire vectors.

Is a finite list a sequence?

Yes, finite ordered lists are commonly called finite sequences; the formal infinite definition uses all natural-number indices.

Does a convergent sequence have to reach its limit?

No. In the worked example, every finite term is below six even though the limit is six.

Check your understanding

Do (A,B,A) and (A,A,B) represent the same sequence because they contain the same symbols?

Answer: No. Their second and third positions differ. Their sets of distinct elements are the same, but their sequences are different.

Related terms

  • Time series
  • Token
  • Convergence
  • Stochastic process
  • recurrence relation
  • subsequence

Learn next

Read convergence and recurrence relation. Change the worked example's initial value to ten, derive the new formula and determine whether the limit changes. Then explain why a reversed event history generally represents different information.

  • Convergence

More in Mathematics and optimization

  • Absolute error loss - Absolute error loss measures a numerical prediction's error as the absolute difference between its predicted and reference values: L(y,y-hat)=|y-y-hat|.
  • Active-set method - An active-set method is an optimization approach that works with a changing subset of constraints believed to be tight at the solution.
  • Adjoint state method - The adjoint state method computes how a chosen objective changes when the parameters of a mathematical model change.
  • Σ-algebra
  • Algebraic connectivity - Algebraic connectivity is the second-smallest eigenvalue of a graph's Laplacian matrix.
  • Algorithm IMED - Algorithm IMED, short for Indexed Minimum Empirical Divergence, is a method for choosing actions in a stochastic multi-armed bandit problem.

Sources

Aalto Dictionary of Machine Learning, sequence and convergence: https://aaltodictionaryofml.github.io/ADictML_Main.pdf. Mathematical indexing and limit terminology. The recurrence, subsequence comparison and fictional event-processing scenario are original teaching examples.

Previous: Separation test Next: Sequence analysis in social sciences

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer