# Is the calculation of variance correct from an estimator — confusion regarding complex number where I am going wrong?

I have an expression for the varaince of measurement noise obtained from an estimator. The measurement noise is additive white gaussian having values in complex domain. I have squared the term $(.)^2$, should I be squaring or just implement without squaring? But if I dont square the term, then I am getting a complex valued variance which is incorrect as variance is always real valued.

Kindly suggest what to do.

You must put:

$$\sigma^2=\frac{1}{N-1}\sum_{i=1}^N(y_i-\hat{y}_i)\overline{(y_i-\hat{y}_i)}$$

that is, replacing your code by:

for i = 1: N
dy(i,1) = (y(i)-yhat(i))*conj(y(i)-yhat(i));
end
sigma2 = 1/(N-1)*sum(dy);


The variance is the second moment of a probability distribution, which can be defined for any metric space in the sense of the definition over the random variable (integral of a density), or in any vector space, in the sense of the estimator of the random variable (sum of n samples).

For $X$ a random variable $\in \mathbb{R}^n$, with probability density function $p(x):I_X \subset \mathbb{R}^n \rightarrow \mathbb{R}$, the second moment $\in \mathbb{R}$ is:

$$\sigma^2=\mathbf{E}\{(X-\mu)^2\}=\int_{I_X} (x-\mu)^2 p(x)dx$$

which is the variance for $n=1$ and the covariance matrix in general.

For other fields $\mathbb{F}$, complex and even real numbers, the metric $d(x,y): \mathbb{F}x\mathbb{F}\rightarrow \mathbb{R}$ can redefine the moment definition

$$\sigma^2_{\mathbb{F}}=\mathbf{E}_{\mathbb{F}}\{(X-\mu)^2\}=\int_{I_X} d(x,\mu)^2 p(x)dx$$

For example, for the complex field, the metric function can be the standard distance from the hermitian inner product, and thus we have the variance definition:

$$d(x,y)=\sqrt{(x-y)\overline{(x-y)}}$$ $$\sigma^2_{\mathbb{C}}=\mathbf{E}_{\mathbb{C}}\{(X-\mu)^2\}=\int_{I_X} (x-y)\overline{(x-y)} p(x)dx$$

But the standard product, without the conjugated term, though can be a valuable figure (named as the "complementary variance") is not a second moment:

$${\sigma^2}_{\mathbb{C}comp}=\int_{I_X} (x-y)^2 p(x)dx$$

Of course, you always could be more "reasonable" and prefer to drop the complex analysis and move onto a $\mathbb{C}^2$ cartesian plane, and start taking covariances instead of a single number which dont dive you the full distribution information of your stochastics.

• Thank you for your reply, I have taken the complex conjugate of the second term if you may kindly see the code in my question. Moreover, there is a multiplication term with $y$ in the expression $(y(y-yhat))$. I took the conjugate for that term and I think you have not mentioned this part which is how to handle multiplication with iteself for scalar complex valued number. What I have done is the same as your answer except for the doubt in the term $y_n \times y_n$. I plugged you code and still I am getting very large value for the variance like 2 to three digit number. – SKM Dec 4 '16 at 19:06
• I checked your code and you are calculating a different expression which dont make any known symmetry to me. You should take A=y(i) and B=yhat(i). The square root of the result should preserve the dimensional symmetry. Could you plot the point cloud in the z plane and the variance result you are having? – Brethlosze Dec 5 '16 at 2:19
• Besides, you can made two different calculations with A1=real(y(i)) B1=real(yhat(i)) and for A2=imag(y(i)) B2=imag(yhat(i)). sigma1 and sigma2 should trivially preserve the dimensionality...... – Brethlosze Dec 5 '16 at 2:22
• Regarding your comment, the complex product is handled as ussualy defined in the $\mathbb{C}$ field, and there are no y(i)*y(i) terms, only y(i)*conj(y(i)).Do you remember the bracket notation? $<a|b>=a\overline{b}$ – Brethlosze Dec 5 '16 at 2:24
• Ive just checked your questions.... I will address them and kill your doubts one by one.... :) – Brethlosze Dec 7 '16 at 0:28