필터 지우기
필터 지우기

Is var command works also for complex numbers?

조회 수: 12 (최근 30일)
guy lasri
guy lasri 2019년 6월 10일
댓글: Steven Lord 2019년 6월 10일
Hey,
I tried to calculate variance on a complex matrix using the built in function 'var' and compared the results to the equetion 'Var = mean(abs(x).^2)-(abs(mean(x)).^2)'.
I got different results. Any body know why?
This is the code:
x = [1, -1, 1+1i, 1-1i];
Var1 = var(x);
Var2 = mean(abs(x).^2)-(abs(mean(x)).^2);

채택된 답변

Alex Mcaulley
Alex Mcaulley 2019년 6월 10일
If you take a look at the var documentation https://es.mathworks.com/help/matlab/ref/var.html you can see that the definition is not the same than the one you are using:
x = [1, -1, 1+1i, 1-1i];
Var1 = var(x)
Var2 = sum(abs(x-mean(x)).^2)/(numel(x)-1) %Following the definition
Var1 =
1.6667
Var2 =
1.6667
To use your definition of the variance, you have to put:
Var1 = var(x,1)
Var2 = mean(abs(x).^2)-(abs(mean(x)).^2)
Var1 =
1.2500
Var2 =
1.2500
  댓글 수: 2
guy lasri
guy lasri 2019년 6월 10일
Thanks for the fast answer. How is the variance different? And which variance is better for MMSE estimation?
Steven Lord
Steven Lord 2019년 6월 10일
See the second and third paragraphs in the following section of the Wikipedia article on variance.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by