  The approach of an ideal gas to equilibrium is simulated through a
generalization of the Ehrenfest ball-and-box model. In the present model, the
interior of each box is discretized, {\it i.e.}, balls/particles live in cells
whose occupation can be either multiple or single. Moreover, particles
occasionally undergo random, but elastic, collisions between each other and
against the container walls. I show, both analitically and numerically, that
the number and energy of particles in a given box eventually evolve to an
equilibrium distribution $W$ which, depending on cell occupations, is binomial
or hypergeometric in the particle number and beta-like in the energy.
Furthermore, the long-run probability density of particle velocities is
Maxwellian, whereas the Boltzmann entropy $\ln W$ exactly reproduces the
ideal-gas entropy. Besides its own interest, this exercise is also relevant for
pedagogical purposes since it provides, although in a simple case, an explicit
probabilistic foundation for the ergodic hypothesis and for the maximum-entropy
principle of thermodynamics. For this reason, its discussion can profitably be
included in a graduate course on statistical mechanics.
