  In a microcanonical ensemble (constant $NVE$, hard reflecting walls) and in a
molecular dynamics ensemble (constant $NVE\mathbf{PG}$, periodic boundary
conditions) with a number $N$ of smooth elastic hard spheres in a
$d$-dimensional volume $V$ having a total energy $E$, a total momentum
$\mathbf{P}$, and an overall center of mass position $\mathbf{G}$, the
individual velocity components, velocity moduli, and energies have transformed
beta distributions with different arguments and shape parameters depending on
$d$, $N$, $E$, the boundary conditions, and possible symmetries in the initial
conditions. This can be shown marginalizing the joint distribution of
individual energies, which is a symmetric Dirichlet distribution. In the
thermodynamic limit the beta distributions converge to gamma distributions with
different arguments and shape or scale parameters, corresponding respectively
to the Gaussian, i.e., Maxwell-Boltzmann, Maxwell, and Boltzmann or
Boltzmann-Gibbs distribution. These analytical results agree with molecular
dynamics and Monte Carlo simulations with different numbers of hard disks or
spheres and hard reflecting walls or periodic boundary conditions. The
agreement is perfect with our Monte Carlo algorithm, which acts only on
velocities independently of positions with the collision versor sampled
uniformly on a unit half sphere in $d$ dimensions, while slight deviations
appear with our molecular dynamics simulations for the smallest values of $N$.
