# Group testing

An animation of the false coin problem being solved for 10 coins, where the goal is to find the single coin that is lighter than the others. Many fewer than 10 tests are needed since at each stage, at least half of the 'good' coins are eliminated.

In combinatorial mathematics, group testing refers to any procedure which breaks up the task of locating elements of a set which have certain properties into tests on groups of items, rather than on individual elements. A familiar example of this type of technique is the false coin problem of recreational mathematics. In this problem there are n coins and one of them is false, weighing less than a real coin. The objective is to find the false coin, using a balance scale, in the fewest number of weighings. By repeatedly dividing the coins in half and comparing the two halves, the false coin can be found quickly as it is always in the lighter half.[a]

Schemes for carrying out such group testing can be simple or complex and the tests involved at each stage may be different. Schemes in which the tests for the next stage depend on the results of the previous stages are called adaptive procedures, while schemes designed so that all the tests are known beforehand are called non-adaptive procedures. The structure of the scheme of the tests involved in a non-adaptive procedure is known as a pooling design.

## Background

The field of (Combinatorial) Group Testing was introduced by Robert Dorfman in 1943. The motivation arose during the Second World War when the United States Public Health Service and the Selective service embarked upon a large scale project to weed out all syphilitic men called up for induction. Testing an individual for syphilis involves drawing a blood sample from them and then analysing the sample to determine the presence or absence of syphilis. However, at the time, performing this test was expensive, and testing every soldier individually would have been very cost heavy and inefficient.

Supposing there are ${\displaystyle n}$ soldiers, this method of testing leads to ${\displaystyle n}$ separate tests. If we have 70-75% of the people infected then this method would be reasonable. Our goal however, is to achieve effective testing in the more likely scenario where it does not make sense to test 100,000 people to get (say) 10 positives.

The feasibility of a more effective testing scheme hinges on the following property. We can combine blood samples and test a combined sample together to check if at least one soldier has syphilis. This is the central idea behind group testing. If one or more of the soldiers in this group has syphilis, then a test is wasted (more tests need to be performed to find which soldier(s) it was). On the other hand, if no one in the pool has syphilis then many tests are saved.

Modern interest in these testing schemes has been rekindled by the Human Genome Project.[1]

## Types of group-testing algorithm

As well as adaptivity, all group testing algorithms are either combinatorial or probabilistic. A combinatorial algorithm finds all the defectives with certainty. In contrast, a probabilistic algorithm has some non-zero probability of making a mistake (i.e. deciding a defective item is non-defective or vice versa). It is known that zero-error algorithms require significantly more tests asymptotically (in the number of defective items) than algorithms that allow asymptotically small probabilities of error.[4]

Another class of algorithms are so-called noisy algorithms. These deal with the situation that with some non-zero probability, ${\displaystyle q}$, the result of a group test is erroneous (e.g. comes out positive when the test contained no defectives). A noisy algorithm will always have a non-zero probability of making a mistake.

## Formalization of the problem

We now formalize the group-testing problem abstractly.

Let the total number of items to be tested be ${\displaystyle n}$, and an upper bound on the number of defective items be ${\displaystyle d}$. The (unknown) information about which items are defective is described as a vector, ${\displaystyle \mathbf {x} =(x_{1},x_{2},...,x_{n})}$, where ${\displaystyle x_{i}=1}$ if i-th item is defective and ${\displaystyle x_{i}=0}$ otherwise. ${\displaystyle \mathbf {x} }$ is called the input vector.

The Hamming Weight of ${\displaystyle \mathbf {x} }$ is defined as the number of ${\displaystyle 1}$'s in ${\displaystyle \mathbf {x} }$. Hence, ${\displaystyle |\mathbf {x} |\leq d}$ where ${\displaystyle |\mathbf {x} |}$ is the Hamming weight. The vector ${\displaystyle \mathbf {x} }$ is an implicit input since we do not know the positions of the ${\displaystyle 1}$'s. The only way to find out is to run the tests.

### Formal notion of a test

A query/test ${\displaystyle S}$ is a subset of ${\displaystyle [n]}$. The answer to the query ${\displaystyle S\subseteq [n]}$ is defined as follows:

${\displaystyle A(S)={\begin{cases}1,{\mbox{ if }}\displaystyle \sum _{k\in S}x_{k}\geq 1\\0,{\mbox{ otherwise.}}\end{cases}}}$

Note that the addition operation used by the summation is the logical OR, i.e.

${\displaystyle A(S)=\displaystyle \bigvee _{i\in S}x_{i}}$.

### Goal

The goal of group testing is to compute or estimate ${\displaystyle \mathbf {x} }$ and minimize the number of tests required to do so. Here, we have no direct questions or answers. Any piece of information can only be obtained using an indirect query. Group testing is ultimately a question of combinatorial searching. The major issue with such problems is that the solution can grow exponentially in the size of the input.

### Definitions and initial bounds

${\displaystyle t(d,n)}$ is defined as the minimum number of non-adaptive tests that one would have to make to detect all of ${\displaystyle d}$ defective items with a total of ${\displaystyle n}$ items. Similarly, we use ${\displaystyle t^{a}(d,n)}$ to denote the number of adaptive tests that one would have to make to detect all the defective items.

Consider the case when only one person in the group will test positive. Then if we tested in the naive way, in the best case we would at least have to test the first person to find out if he/she is infected. However, in the worst case one might have to end up testing the entire group and only the last person we test will turn out to really be the one who was infected. Hence, ${\displaystyle 1\leq t(d,n)\leq n}$. We also have that ${\displaystyle t^{a}(d,n)\leq t(d,n)}$ due to the fact that any non-adaptive test can be performed by an adaptive test by running all of the tests in the first step of the adaptive test. Adaptive tests can be more efficient than non-adaptive tests since the test can be changed after certain things are discovered.

In summary, ${\displaystyle 1\leq t^{a}(d,n)\leq t(d,n)\leq n}$.

### Mathematical representation of non-adaptive algorithms

A typical group testing setup. A non-adaptive algorithm first chooses the matrix ${\displaystyle M}$, and is then given the vector y. The problem is then to find an estimate for x.

Algorithms for non-adaptive group testing consist of two distinct phases. First, it is decided how many tests to perform and which items to include in each test. This is usually encoded in an ${\displaystyle t\times n}$ binary matrix, ${\displaystyle M}$, where ${\displaystyle t}$ is the number of tests and ${\displaystyle n}$ is the total number of items. Each column of ${\displaystyle M}$ represents an item and each row represents a test, with a ${\displaystyle 1}$ in the (i,j)th entry indicating that the i-th test included the j-th item and a ${\displaystyle 0}$ indicating otherwise. In the second phase, often called the decoding step, the results of each group test are analysed to determine which items are likely to be defective.

As well as the vector ${\displaystyle \mathbf {x} }$ (of length ${\displaystyle n}$) that describes the (unknown) defective set, we introduce the vector ${\displaystyle \mathbf {y} }$, of length ${\displaystyle t}$, describing the results of each test. A ${\displaystyle 1}$ in the j-th entry of ${\displaystyle \mathbf {y} }$ indicates that the j-th test was positive (i.e. contained at least one defective). With these vectors the problem can be reframed as follows: first we choose some testing matrix, ${\displaystyle M}$, after which we are given ${\displaystyle \mathbf {y} }$. Then the problem is to analyse ${\displaystyle \mathbf {y} }$ to find some estimate for ${\displaystyle \mathbf {x} }$.

These notions can be expressed more formally as follows. Let ${\displaystyle S\subseteq [n]}$ be a test and define ${\displaystyle \chi _{i}\in \{0,1\}^{n}}$ such that ${\displaystyle i\in S\Leftrightarrow \chi _{s}(i)=1}$, so the k-th test is described by ${\displaystyle \chi _{k}}$. Let ${\displaystyle M}$ be the ${\displaystyle t\times n}$ matrix with rows ${\displaystyle \chi _{i}}$, so that ${\displaystyle (M)_{i,j}=\chi _{i}(j)}$. This construction is based on the grounds that non-adaptive testing with ${\displaystyle t}$ tests is represented by a ${\displaystyle t}$-subset ${\displaystyle S_{i}\subseteq [n]}$ where ${\displaystyle 1\leq i\leq t}$.

Under this setup, ${\displaystyle \mathbf {y} }$ is defined by the matrix multiplication relation: ${\displaystyle M\mathbf {x} =\mathbf {y} }$, where multiplication is logical AND (${\displaystyle \wedge }$) and addition is logical OR (${\displaystyle \vee }$). Here, ${\displaystyle \mathbf {y} }$ will have a ${\displaystyle 1}$ in position ${\displaystyle i}$ if and only if ${\displaystyle (M)_{i,j}}$ and ${\displaystyle \mathbf {x} _{j}}$ are both ${\displaystyle 1}$ for any ${\displaystyle j}$. That is, if and only if at least one defective item was included in the i-th test.

## Generalized binary splitting algorithm

The generalized binary splitting algorithm is an essentially-optimal adaptive group-testing algorithm that proceeds as follows:[5][6]

1. If ${\displaystyle n\leq 2d-2}$, test the ${\displaystyle n}$ items individually. Otherwise, set ${\displaystyle l=n-d+1}$ and ${\displaystyle \alpha =\lfloor \log {l/d}\rfloor }$.
2. Test a group of size ${\displaystyle 2^{\alpha }}$. If the outcome is negative, every item in the group is declared to be non-defective; set ${\displaystyle n:=n-2^{\alpha }}$ and go to step 1. Otherwise, use a binary search to identify one defective and an unspecified number, called ${\displaystyle x}$, of non-defective items; set ${\displaystyle n:=n-1-x}$ and ${\displaystyle d:=d-1}$. Go to step 1.

The generalized binary splitting algorithm requires no more than ${\displaystyle T}$ tests where ${\displaystyle T={\begin{cases}n&n\leq 2d-2\\(\alpha +2)d+p-1&n\geq 2d-1\end{cases}}}$.

Non-adaptive group-testing algorithms tend to assume that the number of defectives, or at least a good upper bound on them, is known.[7] We will denote this quantity ${\displaystyle d}$. If no bounds are known, there are non-adaptive algorithms with low query complexity that can help estimate ${\displaystyle d}$.[8]

### Combinatorial Orthogonal Matching Pursuit (COMP)

An illustration of the COMP algorithm. COMP identifies item a as being defective and item b as being non-defective. However, it incorrectly labels c as a defective, since it is “hidden” by defective items in every test in which it appears.

Combinatorial Orthogonal Matching Pursuit, or COMP, is a simple non-adaptive group-testing algorithm that forms the basis for the more complicated algorithms that follow in this section.

First, each entry of the testing matrix is chosen i.i.d. to be ${\displaystyle 1}$ with probability ${\displaystyle 1/d}$ and ${\displaystyle 0}$ otherwise.

The decoding step proceeds column-wise (i.e. by item). If every test in which an item appears is positive, then the item is declared defective; otherwise the item is assumed to be non-defective. Or equivalently, if an item appears in any test whose outcome is negative, the item is declared non-defective; otherwise the item is assumed to be defective. Of particular note here is that this algorithm never creates false negatives, though a false positive occurs when all locations with ones in the j-th column of ${\displaystyle M}$ (corresponding to a non-defective item j) are “hidden” by the ones of other columns corresponding to defective items.

The COMP algorithm requires no more than ${\displaystyle ed(1+\delta )\ln(n)}$ tests to have an error probability less than or equal to ${\displaystyle n^{-\delta }}$.[9]

In the noisy case, we relax the requirement in the original COMP algorithm that the set of locations of ones in any column of ${\displaystyle M}$ corresponding to a positive item be entirely contained in the set of locations of ones in the result vector. Instead, we allow for a certain number of “mismatches” – this number of mismatches depends on both the number of ones in each column, and also the noise parameter, ${\displaystyle q}$. This noisy COMP algorithm requires no requires no more than ${\displaystyle 4.36({\sqrt {\delta }}+{\sqrt {1+\delta }})^{2}(1-2q)^{-2}d\log {n}}$ tests to achieve an error probability at most ${\displaystyle n^{-\delta }}$.[10]

### Definite Defectives (DD)

The definite defectives method is an extension of the COMP algorithm that attempts to remove any false positives. Performance guarantees for DD have been shown to strictly exceed those of COMP.[11]

The decoding step uses a useful property of the COMP algorithm: that every item that COMP declares non-defective is certainly non-defective (that is, there are no false negatives). It proceeds as follows:

1. We first run the COMP algorithm, and remove any non-defectives that it detects. All remaining items are now “possibly defective”
2. Next the algorithm looks at all the positive tests. If an item appears as the only “possible defective” in a test, then it must be defective, so the algorithm declares it to be defective.
3. All other items are assumed to be non-defective. The justification for this last step comes from the assumption that the number of defectives is much smaller than the total number of items.

Note that steps 1 and 2 never make a mistake, so the algorithm can only make a mistake if it declares a defective item to be non-defective. Thus the DD algorithm can only create false negatives.

### Sequential COMP (SCOMP)

SCOMP is an algorithm that makes use of the fact that DD makes no mistakes until the last step, were we assume remaining items to be defective. Let the set of declared defectives be ${\displaystyle K}$. We say that a positive test is explained by ${\displaystyle K}$ if it contains at least one item in ${\displaystyle K}$. The key observation with SCOMP is that the set of defectives found by DD may not explain every positive test, and that every unexplained test must contain a hidden defective.

The algorithm proceeds as follows:

1. First carry out steps 1 and 2 of the DD algorithm to obtain ${\displaystyle K}$, an initial estimate for the set of defectives.
2. If ${\displaystyle K}$ explains every positive test, terminate the algorithm: ${\displaystyle K}$ is our final estimate for the set of defectives.
3. If there are any unexplained tests, find the “possible defective” that appears in the largest number of unexplained tests, and declare it to be defective (that is, add it to the set ${\displaystyle K}$). Go to step 2.

In simulations, SCOMP has been shown to perform close to optimally.[12]

## Bounds

In the combinatorial setup, there are a number of upper and lower bounds on t(d,n) (and t^a(d,n)), the minimum number of tests required to detect all defectives.

### Lower bound on ${\displaystyle t^{a}(d,n)}$

Fix a valid group testing scheme with ${\displaystyle t}$ tests. Now, for two distinct input vectors ${\displaystyle \mathbf {x} }$ and ${\displaystyle \mathbf {x} ^{\prime }}$ where ${\displaystyle |\mathbf {x} |,|\mathbf {x} ^{\prime }|\leq d}$, the resulting vectors will not be the same i.e. ${\displaystyle \mathbf {y(x)} \neq \mathbf {y(x^{\prime })} }$, were ${\displaystyle \mathbf {y(x)} }$ is the resultant for input vector ${\displaystyle \mathbf {x} }$. This is because two valid inputs will never give us the same result. If this ever happened, then we would always have an error in finding both ${\displaystyle \mathbf {x} }$ and ${\displaystyle \mathbf {x} ^{\prime }}$. This gives us that the total number of distinct results is the volume of a Hamming Ball of radius ${\displaystyle d}$, centered about ${\displaystyle n}$ i.e. ${\displaystyle Vol_{2}(d,n)}$. However, for ${\displaystyle t}$ bits, the total number of possible distinct vectors is ${\displaystyle 2^{t}}$. Hence, ${\displaystyle 2^{t}\geq Vol_{2}(d,n)}$. Taking the ${\displaystyle \log }$ on both sides gives us ${\displaystyle t\geq \log\{Vol_{2}(d,n)\}}$.

Now, ${\displaystyle Vol_{2}(d,n)\geq {n \choose d}\geq \left({\frac {n}{d}}\right)^{d}}$. Therefore, we will end up having to perform a minimum of ${\displaystyle d\log {\frac {n}{d}}}$ tests.

Thus we have proved that ${\displaystyle t^{a}(d,n)\geq d\log {\frac {n}{d}}}$

### Upper bound on ${\displaystyle t^{a}(d,n)}$

${\displaystyle t^{a}(d,n)\leq O(d\log {n})}$.

Since we know that the upper bound on the number of positives is ${\displaystyle d}$, we run a binary search at most ${\displaystyle d}$ times or until there are no more values to be found. To simplify the problem we try to give a testing scheme that uses ${\displaystyle O(\log {n})}$ adaptive tests to figure out a ${\displaystyle i}$ such that ${\displaystyle x_{i}=1}$. The related problem is solved by splitting ${\displaystyle [n]}$ in two halves and querying to find a ${\displaystyle 1}$ in one of those and then proceeding recursively to find the exact position in the half where the query returned a ${\displaystyle 1}$. This will take ${\displaystyle 2\lceil \log {n}\rceil }$ time or if the first query is performed on the whole set, it will take ${\displaystyle \lceil \log {n}\rceil +1}$. Once a ${\displaystyle 1}$ is found, the search is then repeated after removing the ${\displaystyle i^{th}}$ co-ordinate. This can be done at most ${\displaystyle d}$ times. This justifies the running time of ${\displaystyle O(d\log {n})}$. For a full proof and an algorithm for the problem refer to: CSE545 at the University at Buffalo

### Upper bound on ${\displaystyle t(1,n)}$

${\displaystyle t(1,n)\leq \lceil \log {n}\rceil }$ This upper bound is for the special case where ${\displaystyle d=1}$ i.e. there is a maximum of 1 positive. In this case, the matrix multiplication gets simplified and the resultant ${\displaystyle \mathbf {y} }$ represents the binary representation of ${\displaystyle i}$ for test ${\displaystyle i}$. This gives a lower bound of ${\displaystyle \lceil \log {n}\rceil }$. Note that decoding becomes trivial because the binary representation of ${\displaystyle i}$ gives us the location directly. The group test matrix here is just the parity check matrix ${\displaystyle H_{m}}$ for the ${\displaystyle [2^{m}-1,2^{m}-m-1,3]}$ Hamming code.

Thus as the upper and lower bounds are the same, we have a tight bound for ${\displaystyle t(d,n)}$ when ${\displaystyle d=1}$. Such tight bounds are not known for general ${\displaystyle d}$.

### Upper bounds for non-adaptive group testing

For non-adaptive group testing upper bounds we shift focus toward disjunct matrices, which have been used for many of the bounds because of their nice properties. It has been shown that ${\displaystyle \Omega \left({\frac {d^{2}}{\log {d}}}\log {n}\right)\leq t(d,n)}$. Also for upper bounds we currently have ${\displaystyle t(d,n)\leq {\mathcal {O}}(d^{2}\log {n})}$ with a strongly explicit construction. So the smallest upper bound and biggest lower bound they are only off by a factor of ${\displaystyle 1/\log {d}}$, which is fairly small.

Separately, we can see that the current known lower bound for ${\displaystyle t(d,n)}$ is already a factor of ${\displaystyle d/\log {d}}$ larger than the upper bound for ${\displaystyle t^{a}(d,n)}$.

## Notes

1. ^ A bit more precisely – if there are an odd number of coins to be weighed, pick one to put aside and divide the rest into two equal piles. If the two piles have equal weight, the bad coin is the one put aside, otherwise the one put aside was good and no longer has to be tested.

## References

• Colbourn, Charles J.; Dinitz, Jeffrey H. (2007), Handbook of Combinatorial Designs (2nd ed.), Boca Raton: Chapman & Hall/ CRC, ISBN 1-58488-506-8
• Atia, George Kamal; Saligrama, Venkatesh (2009). "Boolean Compressed Sensing and Noisy Group Testing". IEEE Transactions on Information Theory. 58 (3): 1880–1901. arXiv:. doi:10.1109/TIT.2011.2178156.
• Ding-Zhu, Du; Hwang, Frank K. (1993). Combinatorial group testing and its applications. Singapore: World Scientific. ISBN 9810212933.
• Hwang, Frank K. (September 1972). "A Method for Detecting All Defective Members in a Population by Group Testing". Journal of the American Statistical Association. 67 (339): 605–608. doi:10.2307/2284447. JSTOR 2284447.
• Chun Lam Chan; Pak Hou Che; Jaggi, Sidharth; Saligrama, Venkatesh (2011), Non-adaptive probabilistic group testing with noisy measurements: Near-optimal bounds with efficient algorithms, arXiv: [cs.IT]
• Sobel, Milton; Elashoff, R. M. (1975). "Group testing with a new goal, estimation". Biometrika. 62 (1): 181–193. doi:10.1093/biomet/62.1.181.
• Aldridge, Matthew; Baldassini, Leonardo; Johnson, Oliver (June 2014). "Group Testing Algorithms: Bounds and Simulations". IEEE Transactions on Information Theory. 60 (6): 3671–3687. doi:10.1109/TIT.2014.2314472.
• Atri Rudra's course on Error Correcting Codes: Combinatorics, Algorithms, and Applications (Spring 2007), Lectures 7.
• Atri Rudra's course on Error Correcting Codes: Combinatorics, Algorithms, and Applications (Spring 2010), Lectures 10, 11, 28, 29
• Dorfman, R. (December 1943), "The Detection of Defective Members of Large Populations", The Annals of Mathematical Statistics, 14 (4): 436–440, JSTOR 2235930
• Du, D., & Hwang, F. (2006). Pooling Designs and Nonadaptive Group Testing. Boston: Twayne Publishers.
• Ely Porat, Amir Rothschild: Explicit Non-adaptive Combinatorial Group Testing Schemes. ICALP (1) 2008: 748-759
• Kagan, Eugene; Ben-gal, Irad (2014), "A group testing algorithm with online informational learning", IIE Transactions, 46: 164–184, doi:10.1080/0740817X.2013.803639, ISSN 0740-817X