0

I have an output from a noisy signal, saved as a set of cosines.

I have a set of frequencies from 0 to x Hz (x is a large number), and a set, of the same size, of amplitudes.

I want to work out the harmonic mean of the frequencies present, when the weighting of the frequency is the magnitude of the corresponding amplitude.

For example: If I have a set of frequencies [ 1 , 2 , 3] and amplitudes [ 10, 100, 1000 ] (such that the cosine with frequency 1 has amplitude 10, etc.). Then, the harmonic mean of the frequencies is 2.8647.

However, I run into problems when I have a zero frequency (a "DC" component) - the harmonic mean is just zero!

The real life problem is a very big set of cosines, starting with a zero frequency, going up to several GHz. Much of the signal is weighted in a portion of the spectrum and I want to compare a simple weighted mean of the spectrum with a harmonic mean.

The way around this (it seems a cheap way) is to ignore the zero frequency - it is only one frequency out of tens of thousands. But is there a correct way to do this?

Dev-iL
  • 23,742
  • 7
  • 57
  • 99
William
  • 37
  • 7
  • How do you compute the harmonic mean that you mentioned? `harmmean(1:3) == 1.6364`. – Dev-iL Dec 29 '16 at 11:22
  • Hi Devil - I was not clear enough: I am calculating the weighted harmonic mean. Each data point (frequency) [1,2,3] has a weight (magnitude)[10,100,1000] (these are just example weights). – William Dec 29 '16 at 11:38
  • so a more pertinent example would be the set of frequencies – William Dec 29 '16 at 11:55

1 Answers1

0

Below is the equation for the weighted harmonic mean:

Weighted harmonic mean

Applied to your example it's:

x = 1:3;
w = logspace(1,3,3);  % [10 100 1000]
sum(w)/sum(w./x); % 2.8220

You can see that if one of the x values is 0, the sum in the denominator would be infinite. If you manually set the weight of this value to 0, you would have a 0/0 scenario in the bottom sum (which evaluates to NaN). Technically speaking - you can't have an x of 0 in the computation of this type of mean without getting a result of 0.

I think it's quite clear that this isn't the right tool to handle a DC signal. Several things come to mind in order to get some meaningful information:

  • It sounds reasonable to ignore the DC signal altogether in both means.
  • Perhaps you would be better off ignoring it for the purpose of the harmonic mean and add it afterwards for compatibility with the simple mean.

At the end of the day, you need to decide what is the point you're trying to make with this, and then process the data accordingly.

Community
  • 1
  • 1
Dev-iL
  • 23,742
  • 7
  • 57
  • 99
  • Hi Devil - yes, the mean is 2.822 (the figure above must have been some weird copy and paste error, I have checked!). Your points made re-iterate my concern about an infinity in the denominator. I was just wondering if there is a "correct" (or meaningful) way to deal with such data. I'm erring on the side of ignoring the 0 Hz component (it has a very very small weighting in most cases). Cheers, W – William Dec 29 '16 at 13:23