# Expectation value of standard deviation

I was trying to calculate the expectation value of the standard deviation, if I only take two data points into account. My code is the following:

n[x_] = PDF[NormalDistribution[μ, σ], x];
σ2[x1_, x2_] =
FullSimplify[
Sqrt[1/2*((x1 - (x1 + x2)/2)^2 + (x2 - (x1 + x2)/2)^2)]];
E2[x1_, x2_] = σ2[x1, x2]*n[x1]*n[x2]
Assuming[{σ > 0, μ > 0},
Integrate[
E2[x1, x2], {x1, -Infinity, Infinity}, {x2, -Infinity, Infinity}]]


The results I get are:

$$\frac{\sqrt{(\text{x1}-\text{x2})^2} e^{-\frac{(\text{x1}-\mu )^2}{2 \sigma ^2}-\frac{(\text{x2}-\mu )^2}{2 \sigma ^2}}}{4 \pi \sigma ^2}$$ $$0$$

Where the first line is the function I integrate from $-\infty$ to $\infty$ in two dimension. The result $0$ can not be true since both parts, the exponential and the root are non-negative functions and clearly give a positive value for almost all possible values.

I must have made some mistake at some point, but I do not know where...

• A manual derivation for me yields (σ/(2 Sqrt[2]π)) Integrate[Exp[-x1^2/2 - x2^2/2]Piecewise[{{x2 - x1, x2 > x1}}, x1 - x2], {x1, -∞, ∞}, {x2, -∞, ∞}]. However, Assuming[{x1, x2, μ} ∈ Reals && σ > 0, Expectation[StandardDeviation[{x1, x2}], {x1 \[Distributed] NormalDistribution[μ, σ], x2 \[Distributed] NormalDistribution[μ, σ]}]] yields 0. Hmm... – J. M. is away Aug 16 '17 at 15:38
• Assuming[σ > 0 && μ > 0 && {x1, x2} ∈ Reals, Integrate[FullSimplify[E2[x1, x2]], {x1,-∞, ∞}, {x2,-∞,∞}]] gives σ/Sqrt[π]  – rhermans Aug 16 '17 at 16:04