Use uniform-envelope rejection sampling for a beta distribution. Put for and choose . For , differentiation of gives the mode , so
If or , take ; this also covers . Draw and accept it if
Otherwise continue with the next independent pair. The probability of acceptance is , so the procedure terminates almost surely. Conditional on acceptance, the probability density function is proportional to , hence is exactly the beta distribution of parameters . The restriction guarantees the bounded uniform envelope.