Distributions of the ratios of independent beta variables and applications