Antibodies are the standard biomolecule for marking molecular structures and delivering drugs due to their specific binding capabilities. However, they are expensive to produce and their relatively large size prevents their easy traversal of bi-lipid membranes. Over the past 30 years, molecular recognition has also been achieved through the use of aptamers, short oligonucleotide sequences that fold in conformations that allow them to specifically bind to targets. These aptamers are produced rapidly and efficiently through a process known as Systematic Evolution of Ligands by EXponential enrichment (SELEX) whereby a molecular selection mechanism based on competitive binding enriches the population of given strands and removes unwanted sequences, yielding high target specificity and affinity. Current SELEX mathematical models are formulated in the mass action limit, which assumes large aptamer/target concentrations. Low number effects, such as the extinction probability of the best binding aptamer, however, require a full stochastic model currently lacking in the literature. We derive such a statistical mechanics model verifying that in the large aptamer/target concentration limit, the mass action results are recovered. Our stochastic model also allows us to calculate the extinction probability and efficiency of selection, and to propose a method of optimizing the SELEX protocol.