Accept/reject for beta distribution I am required to show that the following accept/reject algoritmh produces observations from a beta distribution with parameters $\alpha$ and $\beta$.



*

*Generate $U_1$ and $U_2$ iid uniform(0,1) random variables. Set $V_1=U^{1/{\alpha}}$ and $V_2=U_2 ^{1/{\beta}}$

*Set $W=V_1+V_2$. If $W\leq 1 $, set $X=V_1 /W $; else go to step 1.

*Deliver $X$



Thus, I need to find the conditional distribution of step 2. Now we have:
$$P \left[X \leq x \right]= P \left[ V_1 /W \leq x | W \leq 1 \right]= \frac{P \left[V_1 /W \leq x \cap W \leq 1 \right]}{P \left[ W \leq 1 \right]} $$
A simple transformation shows that $V_1 \sim B \left( \alpha ,1 \right) $ and $V_2 \sim B \left(1, \beta \right)$ but other than that I do not know how to proceed as I cannot simplify the fraction. Had I known the distribution of $W=V_1+V_2$ things would have been  easier but this is not the case here.
Can you please help me compute these probabilities? Thank you.
 A: First, it should be a Beta($\alpha, 1$) and Beta($\beta, 1$). Look at the numerator.
$$
P(V_1 / W \le x \cap W \le 1)
= \int_0^1 \int_0 ^ {wx} f_{V_1}(v) f_{V_2}(w - v) \ dv \ dw,
$$
using a substitution to get $f_{V_1, W}$ from $f_{V_1, V_2}$. Next, interchange order of integration
$$
\int_0 ^ x \int_{v/x} ^ 1 \alpha v^{\alpha - 1} \beta (w - v)^{\beta - 1} \ dw \ dv
= \int_0 ^ x \alpha v^{\alpha - 1}\left[(1 - v)^\beta - v^\beta \left(\frac{1 - x}{x}\right)^\beta\right]. 
$$
If $g(x)$ is the density of our proposed rejection sampler, then $g(x)$ is equal to the derivative of this expression, up-to a factor of $P(W \le 1)$, 
$$
g(x) \propto \frac{d}{dx} \int_0 ^ x \alpha v^{\alpha - 1}\left[(1 - v)^\beta - v^\beta \left(\frac{1 - x}{x}\right)^\beta\right]. 
$$
By Leibniz rule, 
$$
g(x) \propto \alpha \underbrace{x^{\alpha - 1} \left[(1 - x)^\beta - x^\beta \left(\frac{1 - x}{x}\right)^\beta\right]}_{= 0} + \int_0 ^ x \frac{d}{dx} \alpha v^{\alpha - 1}\left[(1 - v)^\beta - v^\beta \left(\frac{1 - x}{x}\right)^\beta\right] \ dv
\\
\propto \int_0 ^ x v^{\alpha + \beta - 1}  \frac{d}{dx} \left(\frac{1 - x}{x}\right)^\beta \ dv.
$$
This final integral can be evaluated to get
$$
g(x) \propto x^{\alpha - 1}(1 - x)^{\beta - 1}. 
$$
This argument is valid for $x \in [0, 1]$ while the density is trivially $0$ otherwise. This is the kernel of a Beta($\alpha, \beta$) distribution, so the conclusion follows. 
