Higher-Dimensional Arrays for Collections of Numbers

By John Pezzullo

Two-dimensional arrays can be thought of as describing tables of values, with rows and columns (like a block of cells in a spreadsheet), and even higher-dimensional arrays can be thought of as describing a whole collection of tables.

Suppose you measure the fasting glucose on five subjects on each of three treatment days. You could think of your 15 measurements being laid out in a 5×3 table (five subjects by three days). If you want to represent this entire table with a single variable name like Gluc, you can use double-indexing, with the first index specifying the subject (1 through 5) and the second index specifying the day of the measurement (1 through 3).

Under that system, Gluc3,2 or Gluc[3,2] indicates the fasting glucose for subject 3 on day 2. And Gluci,j or Gluc[i,j] indicates the fasting glucose for the ith subject on the jth day.

Special terms are sometimes used to refer to arrays with one or two dimensions:

  • A one-dimensional array is sometimes called a vector. But this can be confusing, because the word vector is also used in mathematics, physics, and biology to refer to completely different things.

  • A two-dimensional array is sometimes called a matrix (plural: matrices). But this term is usually reserved for two-dimensional arrays of numbers that are going to be manipulated by a special set of mathematical rules called matrix algebra. Mathematical descriptions of multiple regression make extensive use of matrix algebra.