TITLE: The human body's random number generator
QUESTION [39 upvotes]: I remember learning in microbiology that the human body generates antibodies using a random process so that an enormous variety of antibodies can be produced with a simple genetic code.
Now that I'm trying to learn more about random processes, I find this more interesting than I used to. Has anyone developed a mathematical model for how the genetic code generates these random antibodies? Clearly, we'd like the process to be ergodic, so that as many antibody varieties as possible can be produced. The main reason that I'm interested is because there are so many ways that random and pseudo-random numbers are generated, and it would interesting to see what the body "thinks" is a good random antibody generator.
I did a quick google search, finding links such as this paper, but they seem to assume that antibodies are generated randomly without explaining the mechanism.
So, does anyone know if there is a mathematical model for the process that generates random antibodies?
And, Merry Christmas!
Edit: Steve and Tom have provided a great answer and a great comment about related topics that I think provide a good place to start reading. For now, though, I will leave the question open in case someone can provide a fuller answer in the future. End Edit.

REPLY [8 votes]: I don't know about how the human body does it, but a state-of-the art way that humans perform "complementarity-determining region sequence design" artificially is to optimize "for protein binding by utilizing a hidden Markov model that was trained on all antibody-antigen cocrystal structures in the Protein Data Bank". 
Maximum-entropy models have also been applied to understand the repertoire.
FOLLOWUP:
"Stochastic rearrangement of germline V-, D-, and J-genes to create variable coding sequence for certain cell surface receptors is at the origin of immune system diversity. This process, known as “VDJ recombination”, is implemented via a series of stochastic molecular events involving gene choices and random nucleotide insertions between, and deletions from, genes...we develop a maximum likelihood inference method to [infer the probability distribution of hidden recombination events]...The generative event statistics are consistent between individuals, suggesting a universal biochemical process."