  At finite temperature the distribution of the total momentum is an observable
characterizing the thermal state of a field theory, and its cumulants are
related to thermodynamic potentials. In a relativistic system at zero chemical
potential, for instance, the thermal variance of the total momentum is a direct
measure of the entropy. We relate the generating function of the cumulants to
the ratio of a path integral with properly shifted boundary conditions in the
compact direction over the ordinary partition function. In this form it is well
suited for Monte-Carlo evaluation, and the cumulants can be extracted
straightforwardly. We test the method in the SU(3) Yang--Mills theory, and
obtain the entropy density at three different temperatures.
