It's almost always based on the Fourier Series. You calculate the harmonics up to some reasonable number, then add them as the square root of the sum of squares of all the harmonic amplitudes, then express that as a ratio to the fundamental amplitude.