I am learning how to use random variables in some applications. In one chapter in the book I am reading, it introduces the application of uniform distribution about a uniform random variable $x$ given in the range $[a,b]$ ($b>a>0$) with distribution function $$ \frac{1}{b-a} $$ So to find the average of such random variable $x$ as $$ \overline{x} = \int_a^b \frac{x}{b-a}dx = \frac{a+b}{2} $$ In the computer language I choose, it only gives me a function about the uniform random variable ranges in [0, 1] so I do the following transformation $$ y = a + (b-a)x $$ where $x \sim \text{U}(0,1)$ instead of [a, b] and the average of $y$ is now (should not change of course) $$ \overline{y} = \int_0^1 a+(b-a)xdx = \frac{a+b}{2} $$
Now if we consider a skewed distribution such that $$ z = a + (b-a)x^2 $$ with $x \sim \text{U}(0,1)$ so z will be within [a, b] (non-uniformly). Do we have to find the probability function for $x^2$ and go the average from there or we can simply do the following integral?
$$ \overline{z} = \int_0^1 a+(b-a)x^2dx = \frac{2a+b}{3} $$
I am trying to verify this result by finding the distribution function for $x^2$ with $X\sim \text{U}(a, b)$by following some instructions online: set $Y = X^2$ and find $$P(Y\leq y) = P(X^2\leq y) = P(|X|\leq \sqrt{y}) = F_X(\sqrt{y}) - F_X(-\sqrt{y})$$ After some albegra, I found $$f_Y(Y=y) = \frac{1}{(b-a)\sqrt{y}}, \quad y\in(0,1]$$
The average is then $$ \overline{y} = \int_0^1 y f_Y(y)dy = \frac{2}{3(b-a)} $$
It is a different result. I am trying to verify it several times but I still don't know what is wrong with my computation.
You had everything correct until $P(|X|\le\sqrt{y})$. First of all if $X\sim U(0,1)$, then $X\ge 0$ and you don't need abs value.
Then, function $F_X(x) = x$ if $0\le x\le1$, so for $0\le y\le1$, $F_Y(y)=F_X(\sqrt y)=\sqrt y$ and $f_Y(y) = \frac1{2\sqrt{y}}$. Where did $a$ and $b$ come from here?
Finally, by integrating, you can find out that $\bar y=\overline{x^2} = \frac13$ which is consisting with the answer you found earlier.