Solution (source code)

= Solution

When the relevant <moments> are finite, the <mean> and <variance> are
$$
\boxed{\mu=\mathbb E[X]=\int_{-\infty}^{\infty}x f(x)\,dx,\qquad
\sigma^2=\mathbb E[(X-\mu)^2]=\int_{-\infty}^{\infty}(x-\mu)^2f(x)\,dx.}
$$
Equivalently, $\sigma^2=\int x^2f(x)\,dx-\mu^2$. The <mean> requires an integrable absolute first <moment>; finite second <moment> guarantees both quantities are finite.