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

조회 수: 8(최근 30일)
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
Star Strider
Star Strider 2022년 9월 20일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

David Goodmanson
David Goodmanson 2022년 9월 20일
편집: David Goodmanson 2022년 9월 22일
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
David Goodmanson
David Goodmanson 2022년 9월 23일
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.

댓글을 달려면 로그인하십시오.

추가 답변(0개)

범주

Find more on Mathematics and Optimization in Help Center and File Exchange

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by