Given $n$ random variables $X$ where $X$ is Rayleigh distributed, we have the probability density function
$$ f_{X_{i}}(x_{i})=\frac{x_{i}}{\sigma^2}e^{-\frac{x_{i}^2}{2\sigma^2}} \quad \quad \quad i = 1,..,n$$
I have a data set for $x_{i}$ and want to write an expression for estimating $\sigma$ with Least Squares Estimation, by finding the $\sigma$ that minimizes
$$ \sum_{i=1}^n (x_{i}-E(X_{i})) $$
That is to say, I try to set
$$ \frac{d}{d\sigma} \sum_{i=1}^n (x_{i}-E(X_{i})) = 0 $$
and solve for $\sigma$. However, when calculating $E(X_{i})$ I end up with the following improper integral
$$ \int_{-\infty}^{\infty} x_{i}\frac{x_{i}}{\sigma^2}e^{-\frac{x_{i}^2}{2\sigma^2}} dx_{i} $$
which causes a lot of problems. I am not sure how to get rid of the integral in order to calculate the sum for my given data set. How am I supposed to proceed in this case when using Least Squares Estimation?