You want to sample from the Beta distribution with parameters a and b, whose density on [0, 1] is
f(x) = x^(a-1) (1-x)^(b-1) / B(a, b)
where B is the Beta function. Your proposal distribution is the uniform density g(x) = 1 on [0, 1].
Rejection sampling requires an envelope constant M with f(x) <= M g(x) for all x. Compute the smallest valid M, and the acceptance rate of the resulting sampler: the probability that a proposed draw is accepted.
One line with the two real numbers a and b, each with at most 4 digits after the decimal point.
Two real numbers: the smallest valid M and the acceptance rate, each with relative error at most 1e-9.
1 <= a, b <= 100
This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.
Numeric answers are accepted if they are within a relative tolerance of 1e-09 of the expected value.
2 2
1.5 0.6666666666666666
1 1
1.0 1.0