  Biological and artificial neural networks routinely make reliable
distinctions between similar inputs, and the rules for making these
distinctions are learned. In some ways, self/nonself discrimination in the
immune system is similar, being both reliable and (partly) learned through
thymic selection. In contrast to other examples, we show that the distributions
of self and nonself peptides are nearly identical but strongly inhomogeneous.
Reliable discrimination is possible only because self peptides are a particular
finite sample drawn out of this distribution, and the immune system can target
the ``spaces'' in between these samples. In conventional learning problems,
this would constitute overfitting and lead to disaster. Here, the strong
inhomogeneities imply instead that the immune system gains by targeting
peptides which are very similar to self, with maximum sensitivity for sequences
just one substitution away. This prediction from the structure of the
underlying distribution in sequence space agrees, for example, with the
observed responses to cancer neoantigens.
