See the Math The Virial Theorem

The virial of a particle is defined as the product of the particle's momentum, p, and its position, x. The virial theorem states that if the time average of a particle's virial is zero, then the particle's kinetic energy, T, is related to the product of the net force, F, acting on the particle and the particle's position:

virial theorem gif

For particles—or galaxies—moving under the influence of a gravitational force, virial theorem gif is equal to the particle's gravitational potential energy, which depends on the total mass inside the particle's orbit. Fritz Zwicky used the virial theorem to relate the total average kinetic energy and total average potential energy of the galaxies of the Coma cluster. He argued that the virial for a pair of orbiting masses is zero, and used the principle of superposition to extend the argument to a system of interacting mass points. This allowed him to use the position and velocity measurements he carried out to find the mass of the galaxy cluster.