Why doesn't the kurtosis function work properly for complex numbers?

Good morning,
I was trying out the kurtosis function on Matlab with complex numbers, using the following code:
var = sqrt(1/2) * randn(1,1000) + 1i * sqrt(1/2) * randn(1,1000);
var_kurt = kurtosis(var);
I was expecting var_kurt to equal 3, since I'm calculating the kurtosis of a gaussian distributed complex function, but instead I get a value of 68.7674 +18.3410i. However, kurtosis(real(var)) does equal 3, which surprises me since the kurtosis should not depend on the variable being complex. Any idea why this happens?
Thanks very much in advance,
Guillem

1 Comment

The kurtosis function involves raising functions of the argument to the 4th power. In my experience, squaring a complex vector is the operation of multiplying it element-wise by its complex conjugate (the absolute value is the square root of that operation), rather than squaring the real and imaginary elements separately. It would likely be necessary to re-write the function to do that and then square that result to get the 4th power of the complex array that represents your data. The kurtosis function apparently assumes that all the arguments to it will be real.

Sign in to comment.

 Accepted Answer

Hi Guillem,
Both the standard deviation and the variance (std and var) work correctly for complex argument, so kurtosis appears to be a bug in the sense that if Matlab does the other two correctly, why not this one?
For complex data the mean stays complex, and the variance is the sum of (absolute distance)^2 from the mean. For
n = 1e6;
y = sqrt(1/2)*randn(1,n) + i*sqrt(1/2)*randn(1,n);
m = mean(y);
vcalc = sum(abs(y-m).^2)/n
v = var(y,1)
v and vcalc are identical.
The variance uses the '1' option because that version is used to find kurtosis. With the '1' option, the variance is
sum(abs(y-m).^2)/n;
otherwise var divides by (n-1). I wish dividing by n was the default, but somebody else makes the rules.
For kurtosis you need [4th moment about the mean] / [2nd moment about the mean]^2, so the obvious thing to do is
mom2 = sum(abs(y-m).^2)/n % same as vcalc and var(..,1)
mom4 = sum(abs(y-m).^4)/n
kcalc = mom4/mom2^2
k = kurtosis(y)
For real data, these last two agree. For samples from a real normal distribution the kurtosis is close to 3 (not exactly 3 since you are sampling from the distribution) which is correct. For the complex normal distribution used in your code the kurtosis is close to 2, also correct.
As for Matlab kurtosis, it is treating the complex variable just as it would a real variable, which means leaving out the 'abs' in the calculations of the moments above. This leads to a meaningless complex value for kurtosis.

7 Comments

Could you comment on how your defintion of kurtosis for a complex RV compares to equations 7 and 8 in this reference? For one thing, the reference doesn't seem to be taking the central moment, unless the reference is assuming E(z) = 0, which I didn't see. Maybe E(z) = 0 is a standard assumption in the authors' field. Assuming that E(z) = 0, it seems your equation is the first term in equation 7. But equation 7 has a second term that will be nonzero if the complex Gaussian RV is non-circular (I realize that in this Question it is circular). From what I gather, including or not inlcuding the third, constant term in equation 7 depends on one's convention.
Hi David,
Thank you for your input! One last question, where did you find that the kurtosis for a complex normal distribution should be close to 2?
Hi Guillem,
First of all, see Paul's comment above. For a circular (axially symmetric) distribution it looks like the kurtosis is all right, but there is a second term to deal with for noncircular distributions.
For kurosis = 2 in the circular distribution we have here, rather than try to look it up I derived it. So consider x and y to be independent random variables in the xy plane. Since the moment calculations are done with abs(z)^n, doing calculations with |z|^2 = x^2+y^2 is basically the same thing. Assuming mean = 0 and sigma = 1 for simplicity, the pdf for x is
(1/sqrt(2*pi))*exp(-x^2/2)
and similarly for y. Since x and y are independent the overall pdf is the product of pdfs
(1/(2*pi))*exp(-r^2/2)
Its integral in polar coordinates is
Int{0,2*pi} Int{0,inf} (1/(2*pi))*exp(-r^2/2) r dr dtheta
The angle integration takes care of the 2*pi in the denominator, and since the distributions and moments concerned are axially symmetric one can ignore the theta integration from here on out. That leaves
Int{0,inf} exp(-r^2/2) r dr
Substute u = r^2/2, du = r dr then
Int{0,inf} exp(-u) du = 1
so the pdf normalization checks out. The two moments needed for the kurtosis calculation involve expectations of r^2 = 2*u and r^4 = 4*u^2, so
mom2 = <r^2> = Int{0,inf} exp(-u) (2*u) du = 2*1! = 2
mom4 = <r^4> = Int{0,inf} exp(-u) (4*u^2) du = 4*2! = 8
where
Int{0,inf} exp(-u) u^n du = n!
has been used. Then
kurtosis = mom4/mom2^2 = 2.
Interestingly enough, at least to me, is that I couldn't find any references that define the skewness of a complex RV.
Hi Paul,
Yes, interesting about the skewness. The mean, the first moment, only works if it remains complex. The second and fourth moments are real. Does this mean that the skewness, being an odd moment, should remain complex?
I don't know the derivation for complex kurtosis. I'm assuming E(z) = 0, otherwise if you translate all the random variables by a fixed value you get nonuseful results. Besides which, the first page in the reference mentions covariance, which does subtract off the mean.
As you mentioned, the third term for kurtosis does appear to be just a convention, changing kurtosis to excess kurtosis. But there is an analogy for the first two terms of the nonnormalized kurtosis (eq. 8 of the reference) vs. the variance. For complex values the variance is
var = < (z-<z>) (z-<z>)* > = <zz*> - <z><z>*
For kurtosis if the circularity <z^2> is considered to be some kind of mean, then those two kurtosis terms are
kur = < (z^2-<z^2>) (z^2-<z^2>)* > = <(zz*)^2> - <z^2><z^2>*
as in eq. 8. Here it is assumed that the mean has already been subtracted off of z, so <z> = 0.
Hi David,
What do you mean by "the first moment, only works if it remains complex." Works in what sense?
I suspect the skewness, if it's defined, would be complex.
Yes, the reference formula for kurtosis does yield interesting results if E(Z) ~= 0. I wonder if the equation extends to the non-zero E(Z) case by simply replacing Z with Z - E(Z) everywhere.
I'm still getting my head wrapped around what the kurtosis formula means. I guess the first term is measuring the "tail" of the joint density of Re(Z) and Im(Z), and the second term is measuring the degree of non-circularness?
Also, for a complex RV we also have something called the pseudo-variance.
I think I'm going to avoid complex RVs for a while.
Hi Paul,
Oh, it seemed like things were just getting going. What I meant was, the first moment <z> is complex in general, and that property must be retained when computing the variance. |<z>| is a quantity that does no good when subtracting off the mean. Absolute values only come in with the variance, < |(z-<z>)|^2 >.
I modified my previous comment to mention that in the kurtosis formula the z's are assumed to already have the mean subtracted off, so <z> = 0.

Sign in to comment.

More Answers (0)

Products

Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!