Statistical mechanics describes macroscopic systems in terms of statistical ensembles, such as the macroscopic properties of an ideal gas. Ergodic theory is a branch of mathematics arising from the study of statistical mechanics.