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
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.