The immune repertoire can self-organize to a state that minimizes cost and provides protection against infections via competitive evolution of receptor populations stimulated by antigens. Numerical simulations of the population dynamics, as well as its mean-field limit (Eq. 2), show how competition causes a random initial receptor distribution to fragment into a highly peaked pattern [Insets represent ]. Top Right Inset represents the antigenic environment driving the dynamics [generated from a lognormal noise of power spectrum and coefficient of variation 1]. Departure from optimality, as measured by the relative cost gap , decreases with time and eventually reaches zero in the mean-field limit. The three independent runs of the stochastic dynamics show reproducible results. We use the availability function with , a death rate , and a cost function with . The space size is . The initial condition was drawn from a lognormal noise of power spectrum , with coefficient of variation 2 and . In the stochastic simulations, the time between antigen presentations is (200 infections per cell lifetime).