Scale Parameter of Rayleigh Distribution As seen in the cdf of the Rayleigh distribution below, we have a mysterious "scale parameter" $\sigma$:
$$F(x, \sigma)=1-e^{-x^2/\sigma^2}$$
For identically distributed random variables $x_i$, the wikipedia page offers an approximation to this scale parameter as follows:
$$\hat{\sigma}\approx\sqrt{\frac{1}{N}\sum_{i=1}^{N}{}x_i^2}$$
This is a good approximation, and they show an exact calculation for $\sigma$, though it involves some gamma functions that are hard to follow.
Where I'm coming across this is in using some complex data representing radar images, where the distribution of real and imaginary components will have close, though not identical distributions (as in the variance of real components vary slightly from the variance of imaginary components. Or either is skewed slightly, or not exactly 0-mean. We live in an imperfect world). We'll call each complex sample $z_i$.
Deriving an equation from the code, I found my company calculates this scale parameter as follows:
$$\sigma^2=\frac{
             \sum_{i=0}^{N-1}{(|z_i|-\mu)^2}
             -\frac{1}{N} [\sum_{i=0}^{N-1}{(|z_i|-\mu)}]^2
           }{N-1}$$
For some mean of the magnitudes $\mu$, and with $N$ complex samples. It seems to give a good if not better calculation of the scale parameter above (from what I tested in Python and C). It is noted that they call this parameter the "variance" of the data.
Their formula looks similar to the traditional variance calculation.
$$\textrm{Var}[Z]=E[|Z|^2]-|E[Z]|^2$$
However, my company's equation takes the expected value of the difference of the magnitude and mean, rather than just taking the expected value of the magnitude of the data.
Can anyone point me to literature for such an equation for $\sigma^2$, if it is even a valid equation? Or show how it is derived? Is it even a legitimate equation? There is a chance we are just finding the scale parameter wrong.
I would get the answer from within the company, though the original designer is long gone and I'm considered the "expert" on this section. I've tried asking individuals but got a look of confusion similar to my own.
Any help would be appreciated, and thanks in advance!
 A: The limits of the summation can be dropped since you are summing over the entire sample of $N$ observations. Let's use $k$ as the summation index to avoid clash with $i = \sqrt{-1}$.
Your given formula is $\widehat{ \sigma^2 }=\frac1{N-1} \left( \sum{(|z_k|-\mu)^2}
             -\frac{1}{N} \left[\sum{(|z_k|-\mu)} \right]^2 \right)$. Just expand the terms and watch them cancel.
\begin{align*}
(N-1)\widehat{ \sigma^2 } &= \sum\left(|z_k|^2 - 2\mu|z_k| + \mu^2 
\right) -\frac{1}{N} \left[ -N \mu + \sum|z_k| \right]^2 \\
&= \sum|z_k|^2 - \color{blue}{2\mu \sum|z_k|} + \color{magenta}{N\mu^2 } 
 -\frac{1}{N} \left[ \color{magenta}{ N^2 \mu^2 } - \color{blue}{ 2N \mu\sum|z_k|} + \left(\sum|z_k|\right)^2 \right] \\
&= \sum|z_k|^2 - \frac1N \left(\sum|z_k|\right)^2  \\
\end{align*}
Thus for large enough $N$ this $\widehat{ \sigma^2 }\,$is the same as the ordinary (not-so-good) sample variance, where we treat
$$\frac1{N (N-1)} \left(\sum|z_k|\right)^2 \approx \left(\frac{ \sum|z_k| }N\right)^2$$
as the estimate for the square of sample mean.
Anchoring at an auxiliary $\mu$ is a common maneuver to decompose the variance (total variation), which can be conceptually useful. Nonetheless, this theoretical motivation doesn't apply here.
My personal guess is this: in terms of computation, shifting by this arbitrary $\mu$ might provide some numerical stability (guard against round-off error, etc) if $|z_i|$ is typically very small when $\sigma$ is moderately small. It all depends on the actual data.
Finally, note that this deals with an estimate of $\sigma^2$ in general and is NOT specific to the the following given facts:

*

*$|z_k|$ being non-negative

*$z_k = x_k + i y_k$ being complex

*$x_k$ and $y_k$ being non-identical and non-Gaussian with demonstrable skewness.

*Rayleigh distribution

