Everyone else has their opinion on this, so I'll give you mine... The data you get from an FFT is equivalent to a voltage, but complex. To get the power you need to, for each sample, sum the squares of the real and imaginary parts. This gives you the square of the magnitude which is equivalent to power. Energy is not just the sum of the power, it is the integral of power over time. If you just sum the FFT bins (magnitudes squared) you will get a value that is proportional to the energy, but to get the actual value you must adjust for the integration time. So multiply by the number of seconds covered by the FFT. For example, if you sample at 65536 SPS (to make the calcs easy) and your FFT is over 1024 samples, this is 1/64 of a second. So take the sum of the squared magnitudes and then multiply by 1/64 to get the actual energy shown in the FFT. There may be a fudge factor for FFTs. I seem to remember that if you do an FFT and then an inverse FFT (just another FFT) you should get the same result back. But there is a factor of two that has to be thrown in somewhere (do you multiply or divide, I'm not sure, I think you divide). I seem to recall that some include the factor of two in the FFT to get the final magnitudes. Others include this in the inverse FFT, so the FFT is "correct" without the factor. Some split the difference and include the square root of two in each. Am I remembering this right? Where does this go if you want to calculate energy as the OP is doing? Rick
Re: How do I Calculate Log Energy?
Started by ●December 17, 2010
Reply by ●December 18, 20102010-12-18
On 12/17/2010 7:28 PM, rickman wrote:> Everyone else has their opinion on this, so I'll give you mine... > > The data you get from an FFT is equivalent to a voltage, but complex. To get the power you need to, for each sample, sum the squares of the real and imaginary parts. This gives you the square of the magnitude which is equivalent to power. Energy is not just the sum of the power, it is the integral of power over time. If you just sum the FFT bins (magnitudes squared) you will get a value that is proportional to the energy, but to get the actual value you must adjust for the integration time. So multiply by the number of seconds covered by the FFT. For example, if you sample at 65536 SPS (to make the calcs easy) and your FFT is over 1024 samples, this is 1/64 of a second. So take the sum of the squared magnitudes and then multiply by 1/64 to get the actual energy shown in the FFT. > > There may be a fudge factor for FFTs. I seem to remember that if you do an FFT and then an inverse FFT (just another FFT) you should get the same result back. But there is a factor of two that has to be thrown in somewhere (do you multiply or divide, I'm not sure, I think you divide). I seem to recall that some include the factor of two in the FFT to get the final magnitudes. Others include this in the inverse FFT, so the FFT is "correct" without the factor. Some split the difference and include the square root of two in each. Am I remembering this right? Where does this go if you want to calculate energy as the OP is doing? > > Rickhehehehe How much "energy" is in a "bit"? Once you get sampled data then there are all kinds of conversions, etc. to deal with. So, I don't disagree in principle but there's a lot more than a factor of 2 involved here. Actually the factor used depends on the context and the discipline/rules in which one is working. Generally in DSP we use 1/N in the Inverse transform. Some use 1/2pi in a Finite Fourier Transform inverse. Others use 1/sqrt(2pi) in both directions. etc. A good exercise for the student.... Anyway I'd have to think that any expressions of apparent "power" or "energy" would have to be somehow *relative* in view of this. Nothing wrong with that. Fred
Reply by ●December 18, 20102010-12-18
On 18/12/2010 2:28 PM, rickman wrote:> Everyone else has their opinion on this, so I'll give you mine... > > The data you get from an FFT is equivalent to a voltage, but complex. To get the power you need to, for each sample, sum the squares of the real and imaginary parts. This gives you the square of the magnitude which is equivalent to power. Energy is not just the sum of the power, it is the integral of power over time. If you just sum the FFT bins (magnitudes squared) you will get a value that is proportional to the energy, but to get the actual value you must adjust for the integration time. So multiply by the number of seconds covered by the FFT. For example, if you sample at 65536 SPS (to make the calcs easy) and your FFT is over 1024 samples, this is 1/64 of a second. So take the sum of the squared magnitudes and then multiply by 1/64 to get the actual energy shown in the FFT. > > There may be a fudge factor for FFTs. I seem to remember that if you do an FFT and then an inverse FFT (just another FFT) you should get the same result back. But there is a factor of two that has to be thrown in somewhere (do you multiply or divide, I'm not sure, I think you divide). I seem to recall that some include the factor of two in the FFT to get the final magnitudes. Others include this in the inverse FFT, so the FFT is "correct" without the factor. Some split the difference and include the square root of two in each. Am I remembering this right? Where does this go if you want to calculate energy as the OP is doing? > > RickAlso, allow for the window function used. Multiply by 0.5 exactly for a Von Hann window and around 0.5 for most others. Regards, John