# Need to calculate $\frac{E\left[|x(n)|^4\right]}{E\left[x^2(n)\right]}$

I need to calculate $\frac{E\left[|x(n)|^4\right]}{E\left[x^2(n)\right]}$ in real time, where $x(n)$ is complex.

For $E\left[|x(n)|^4\right]$ I plan to take the absolute, raise it to the power $4$ and do exponential averaging with weights $0.999$ and $0.001$. I have no clue on how to calculate $E\left[x^2(n)\right]$. I know that this gives the total signal power. Will this be equivalent to $E\left[|x(n)|^2\right]$?

Thanks, JK

• If you want the power you need $E[|x(n)|^2]$, and not $E[x^2(n)]$. – Matt L. Jun 3 '14 at 9:58

The most efficient way that I can think of to do it would be as follows:

• For each input sample $x[n]$, calculate $|x[n]|^2$. This is more efficient than calculating $|x[n]|$, because you don't have to do the square root:

$$|x[n]| = \sqrt{\text{Re}\{x[n]\}^2+\text{Im}\{x[n]\}^2} \\ |x[n]|^2 = \text{Re}\{x[n]\}^2+\text{Im}\{x[n]\}^2$$

• Average the instantaneous power estimate $|x[n]|^2$ as needed for your application (you mentioned exponential averaging).

• Note that you can also get $|x[n]|^4$ efficiently using this method; you just square the measurement of $|x[n]|^2$ that you made above, then average again as desired.

Focusing on denominator:

By definition $x^2(n)$ is complex:

$$x^2(n) = \Re\{x(n)\}^2 - \Im\{x(n)\}^2 + i2\Re\{x(n)\}\Im\{x(n)\}$$

Therefore:

$$\Re\{x^2(n)\} = \Re\{x(n)\}^2 - \Im\{x(n)\}^2$$

and

$$\Im\{x^2(n)\} = 2\Re\{x(n)\}\Im\{x(n)\}$$

As for division:

$$\frac{1}{E[x^2(n)]} = \frac{E[\Re\{x^2(n)\}] - iE[\Im\{x^2(n)\}]}{|E[\Re\{x^2(n)\}]|^2 - |E[\Re\{x^2(n)\}]|^2}$$

In the end the division operation requires two integration (using 1st order recursive or decaying exponential) one for real part and other for imaginary. Two multiplications to compute the square, one subtraction and one division. I cannot think of any savings in terms of computations here. Others might pitch in.

Numerator

I agree with Jason's approach.