# How can THD (Total Harmonic Distortion) be applied to compare between two signals ( for example between original and encoded signals)?

I would like to compare between two signals (original signal and its encoded version) and plot the scores) as we do with STOI and PESQ. should we calculate the THD for each single signal separately then subtract the scores?

• We need more info about this: what type of signals are comparing and what is the nature of the encoding and decoding process. For perceptual encoders, THD is generally not a good quality metric. Dec 30, 2021 at 12:37
• Thank you @Hilmar for your answer. Here is my explanation: I created a series of harmonics with different frequencies, then I saved it in a file (I'll call it signal_X). Afterward, I've encoded the previously created harmonics with LC3 codec (signal_X_hat). And I would like to compare between : signal_X and signal_X_hat.
– user60790
Dec 30, 2021 at 15:03
• Any mathematical definition of THD between two signal? Dec 31, 2021 at 4:51

Assuming that you know the set of fundamental frequencies, you should be able to calculate the THD for either signal (original or encoded) as $$\frac{\sqrt{v_2^2 + v_3^2 + \ldots + v_n^2}}{v_1}$$ where $$v_1$$ is the signal amplitude at the fundamental frequency and $$v_2, \ldots, v_n$$ are the signal amplitudes at the harmonics of interest for that fundamental frequency.

If there are more than one fundamental frequency, you would include all of them in the denominator and all of the harmonics of interest in the numerator. Since this is a normalized quantity, you can take the difference between the original and encoded signal to get a measure of introduced distortion.

See the Wikipedia link for details.