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

19 views (last 30 days)
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
Star Strider
Star Strider on 20 Sep 2022
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

David Goodmanson
David Goodmanson on 20 Sep 2022
Edited: David Goodmanson on 22 Sep 2022
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
Paul
Paul on 23 Sep 2022
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.
David Goodmanson
David Goodmanson on 23 Sep 2022
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!