To obtain these figures, astronomers attach a spectroscope to a telescope to spread a galaxy’s light into a spectrum. Lines in the spectrum identify common gases within the galaxy. The astronomers know where the lines should be when an object is at rest. However, receding objects show the lines shifted toward the red end of the spectrum. This theory is known as the redshift. It has been determined that the faster a galaxy is receding, the farther away it is.
This process, using the redshift, shows that the universe is expanding. It also allows astronomers to estimate the relative distances to galaxies.