We have investigated the statistics associated with constructing and sampling large protein-encoding libraries. Using fairly simple statistics we have written algorithms for estimating the diversity in libraries generated by the most commonly used protocols, including error-prone PCR, DNA shuffling, StEP PCR, oligonucleotide-directed randomization, MAX randomization, synthetic shuffling, DHR, ADO and SISDC.