True mean of a truncated distribution? I use C++ GSL library to generate random numbers now. The numbers obey a distribution, (e.g. normal or lognormal distribution). This library requires the input of expected value ${\mu}$ (i.e. mean) and std. deviation $\sigma$. I'd like sample random numbers within an interval $(a, b)$. So, when the generated numbers is out of the interval, then that number is discarded. For instance, I'd like to sample numbers having a normal distribution with $\mu$ = 5, $\sigma$ = 0.5, $a$ = 0.5, and $b$ = 10. The $\mu$ must be in the interval $(a, b)$.
The question is: someone said the input $\mu$ and $\sigma$ are not true $\mu$ and $\sigma$ of the sampled numbers, because the pdf $f(x)$ is truncated. But I think, since the input $\mu$ is within the $(a, b)$, and $(a, b)$ is wide enough, they might not be so different.
Is it a big difference between the input and true $\mu$ and $\sigma$? Is it anyway to analytically derive the true values of them?
Maybe, the true $\mu$ is $E(x) = \int_a^bxf(x)dx$? am I right?

Suppose that $G$ is an absolutely continuous distribution, perhaps with support on all real numbers, or some other interval, and $F$ is a truncated distribution with the same pdf, except that it is restricted to have support on $[a,b]$. To write it out in notation,
$$
f(x)= \begin{cases} C g(x) &  x\in[a,b] \\ 
0 &\text{otherwise} \end{cases}
$$
for some constant $C$ which renormalizes the distribution.
When $G$ is an absolutely continuous distribution, we can write the CDF of $F$ as
$$
F(x) = \frac{G(x)-G(a)}{G(b) - G(a)}
$$
and by LOTUS, the distribution $F$ has expectation
$$
\mu=\frac{\int_a^b t d G(t)}{G(b)-G(a)}
$$
and variance
$$
\sigma^2 =\frac{\int_a^b t^2 d G(t)}{G(b)-G(a)} - \mu^2.
$$
