The Statistical Ensemble Approach to Adaptive Immunity