# Weighing matrix

In mathematics, a weighing matrix of order $n$ and weight $w$ is a matrix $W$ with entries from the set $\{0,1,-1\}$ such that:
    $WW^{\mathsf {T}}=wI_{n}$
Where $W^{\mathsf {T}}$ is the transpose of $W$ and $I_{n}$ is the identity matrix of order $n$. The weight $w$ is also called the degree of the matrix. For convenience, a weighing matrix of order $n$ and weight $w$ is often denoted by $W(n,w)$.
Weighing matrices are so called because of their use in optimally measuring the individual weights of multiple objects. When the weighing device is a balance scale, the statistical variance of the measurement can be minimized by weighing multiple objects at once, including some objects in the opposite pan of the scale where they subtract from the measurement.

## Properties

Some properties are immediate from the definition. If $W$ is a $W(n,w)$, then:
* The rows of $W$ are pairwise orthogonal. Similarly, the columns are pairwise orthogonal.
* Each row and each column of $W$ has exactly $w$ non-zero elements.
* $W^{\mathsf {T}}W=wI$, since the definition means that $W^{-1}=w^{-1}W^{\mathsf {T}}$, where $W^{-1}$ is the inverse of $W$.
* $\det W=\pm w^{n/2}$ where $\det W$ is the determinant of $W$.
A weighing matrix is a generalization of a Hadamard matrix, which does not allow zero entries. As two special cases, a $W(n,n)$ is a Hadamard matrix and a $W(n,n-1)$ is equivalent to a conference matrix.

## Applications
### Experimental design

Weighing matrices take their name from the problem of measuring the weight of multiple objects. If a measuring device has a statistical variance of $\sigma ^{2}$, then measuring the weights of $N$ objects and subtracting the (equally imprecise) tare weight will result in a final measurement with a variance of $2\sigma ^{2}$. It is possible to increase the accuracy of the estimated weights by measuring different subsets of the objects, especially when using a balance scale where objects can be put on the opposite measuring pan where they subtract their weight from the measurement.
An order $n$ matrix $W$ can be used to represent the placement of $n$ objects—including the tare weight—in $n$ trials. Suppose the left pan of the balance scale adds to the measurement and the right pan subtracts from the measurement. Each element of this matrix $w_{ij}$ will have:
    $w_{ij}={\begin{cases}0&{\text{if on the }}i{\text{th trial the }}j{\text{th object was not measured}}\\1&{\text{if on the }}i{\text{th trial the }}j{\text{th object was placed in the left pan}}\\-1&{\text{if on the }}i{\text{th trial the }}j{\text{th object was placed in the right pan }}\\\end{cases}}$
Let $\mathbf {x}$ be a column vector of the measurements of each of the $n$ trials, let $\mathbf {e}$ be the errors to these measurements each independent and identically distributed with variance $\sigma ^{2}$, and let $\mathbf {y}$ be a column vector of the true weights of each of the $n$ objects. Then we have:
    $\mathbf {x} =W\mathbf {y} +\mathbf {e}$
Assuming that $W$ is non-singular, we can use the method of least-squares to calculate an estimate of the true weights:
    $\mathbf {y} =(W^{T}W)^{-1}W\mathbf {x}$
The variance of the estimated $\mathbf {y}$ vector cannot be lower than $\sigma ^{2}/n$, and will be minimum if and only if $W$ is a weighing matrix.

### Optical measurement

Weighing matrices appear in the engineering of spectrometers, image scanners, and optical multiplexing systems. The design of these instruments involve an optical mask and two detectors that measure the intensity of light. The mask can either transmit light to the first detector, absorb it, or reflect it toward the second detector. The measurement of the second detector is subtracted from the first, and so these three cases correspond to weighing matrix elements of 1, 0, and −1 respectively. As this is essentially the same measurement problem as in the previous section, the usefulness of weighing matrices also applies.

### Orthogonal designs

An orthogonal design of order $n$ and type $(s_{1},\dots ,s_{u})$ where $s_{i}$ are positive integers, is an $n\times n$ matrix whose entries are in the set $\{0,\pm x_{1},\dots ,\pm x_{u}\}$, where $x_{i}$ are commuting variables. Additionally, an orthogonal design must satisfy:
    $XX^{T}=\sum _{i=0}^{u}s_{i}x_{i}^{2}$
This constraint is also equivalent to the rows of $X$ being orthogonal and each row having exactly $s_{i}$ occurrences of $x_{i}$. An orthogonal design can be denoted as $\mathrm {OD} (n;s_{1},\dots ,s_{u})$. An orthogonal design of one variable is a weighing matrix, and so the two fields of study are connected. Because of this connection, new orthogonal designs can be discovered by way of weighing matrices.

## Examples

Note that when weighing matrices are displayed, the symbol $-$ is used to represent −1. Here are some examples:
This is a $W(2,2)$:
    ${\begin{pmatrix}1&1\\1&-\end{pmatrix}}$
This is a $W(4,3)$:
    ${\begin{pmatrix}1&1&1&0\\1&-&0&1\\1&0&-&-\\0&1&-&1\end{pmatrix}}$
This is a $W(7,4)$:
    ${\begin{pmatrix}1&1&1&1&0&0&0\\1&-&0&0&1&1&0\\1&0&-&0&-&0&1\\1&0&0&-&0&-&-\\0&1&-&0&0&1&-\\0&1&0&-&1&0&1\\0&0&1&-&-&1&0\end{pmatrix}}$
Another $W(7,4)$:
    ${\begin{pmatrix}-&1&1&0&1&0&0\\0&-&1&1&0&1&0\\0&0&-&1&1&0&1\\1&0&0&-&1&1&0\\0&1&0&0&-&1&1\\1&0&1&0&0&-&1\\1&1&0&1&0&0&-\end{pmatrix}}$
Which is circulant, i.e. each row is a cyclic shift of the previous row. Such a matrix is called a $CW(n,k)$ and is determined by its first row. Circulant weighing matrices are of special interest since their algebraic structure makes them easier for classification. Indeed, we know that a circulant weighing matrix of order $n$ and weight $k$ must be of square weight. So, weights $1,4,9,16,...$ are permissible and weights $k\leq 25$ have been completely classified. Two special (and actually, extreme) cases of circulant weighing matrices are (A) circulant Hadamard matrices which are conjectured not to exist unless their order is less than 5. This conjecture, the circulant Hadamard conjecture first raised by Ryser, is known to be true for many orders but is still open. (B) $CW(n,k)$ of weight $k=s^{2}$ and minimal order $n$ exist if $s$ is a prime power and such a circulant weighing matrix can be obtained by signing the complement of a finite projective plane. Since all $CW(n,k)$ for $k\leq 25$ have been classified, the first open case is $CW(105,36)$. The first open case for a general weighing matrix (certainly not a circulant) is $W(35,25)$.

## Equivalence

Two weighing matrices are considered to be equivalent if one can be obtained from the other by a series of permutations and negations of the rows and columns of the matrix. The classification of weighing matrices is complete for cases where $w\leq 5$ as well as all cases where $n\leq 15$. However, very little has been done beyond this with exception to classifying circulant weighing matrices.

## Existence

One major open question about weighing matrices is their existence: for which values of $n$ and $w$ does there exist a $W(n,w)$? The following conjectures have been proposed about the existence of $W(n,w)$:
* If $n\equiv 2{\pmod {4}}$ then there exists a $W(n,w)$ if and only if $w<n-1$ is the sum of two integer squares.
* If $n\equiv 0{\pmod {4}}$ then there exists a $W(n,w)$ for each $w<n$.
* If $n\equiv 4{\pmod {8}}$ then there exists an orthogonal design $\mathrm {OD} (n;1,1)$ for all $k<n$ where $k$ is the sum of three integer squares.
* If $n\equiv 0{\pmod {8}}$ then there exists an orthogonal design $\mathrm {OD} (n;1,k)$ for all $k<n$.
* If $n\equiv 2{\pmod {4}}$ then there exists an orthogonal design $\mathrm {OD} (n;1,k)$ for all $k<n-1$ such that $k=a^{2}$, $a$ an integer.
Although the last three conjectures are statements on orthogonal designs, it has been shown that the existence of an orthogonal design $\mathrm {OD} (n;s_{1},\dots ,s_{u})$ is equivalent to the existence of $X_{1},\dots ,X_{u}$ weighing matrices of order $n$ where $X_{i}$ has weight $s_{i}$.
An equally important but often overlooked question about weighing matrices is their enumeration: for a given $n$ and $w$, how many $W(n,w)$'s are there?