Mark and recapture (source code)

= Mark and recapture
{wiki}

<Mark and recapture> estimates the <cardinality> of a <finite set> of individuals when counting everybody is impractical. The useful information is the overlap between observations: with fixed <sample sizes>, finding many of the same individuals again suggests a smaller population, while finding few suggests a larger one. More elaborate <capture-recapture models> also estimate survival and changing <probabilities> of detection.

In a <closed-population capture-recapture model>, let $N$ be the unknown population <cardinality>. Capture $M$ distinct individuals, mark them, release them all, and allow them to mix with the rest. Next take a second sample of $C$ distinct individuals using <sampling without replacement>, and count the $R$ individuals carrying a mark. The observed marked fraction $R/C$ estimates the population's marked fraction $M/N$, giving the <Lincoln-Petersen estimator>
$$
\frac RC\approx\frac MN,
\qquad \widehat N_{\mathrm{LP}}=\frac{MC}{R}\quad(R>0).
$$
Release happens between the two samples; <sampling without replacement> means that an individual is counted at most once within the second sample. See https://www.maths.otago.ac.nz/~rbarker/Thesis/thesis.pdf[Richard J. Barker, Open Population Mark-Recapture Models, §1.1.1].

For a constructed teaching example, mark $M=20$ individuals and later capture $C=25$, including $R=5$ marked individuals. One fifth of the second sample is marked, suggesting that the twenty marked individuals are one fifth of the population:
$$
\widehat N_{\mathrm{LP}}=\frac{20\cdot25}{5}=100.
$$
Let $A$ and $B$ be the <sets> of individuals in the first and second samples. Their <intersection> has <cardinality> five. By the <inclusion-exclusion principle>, the <set union> contains
$$
|A\cup B|=|A|+|B|-|A\cap B|=20+25-5=40.
$$
Thus $N\geq40$ is an observed lower bound, whereas $100$ is the output of an <estimator> based on the <capture-recapture model>. These are toy counts, not measurements from a medical or ecological study.

\Image[/mark-recapture-overlap-schematic.png]
{title=Forty distinct observed individuals: fifteen in the first sample only, five shared, and twenty in the second sample only}

The diagram shows only observed individuals. It does not draw an assumed population of one hundred. The <capture-recapture model> uses the overlap to infer how many individuals may have escaped both samples; its <likelihood function> shows why one <estimator> output cannot describe all that uncertainty.