Let $X, Y$ be independent random variables where $X \sim Beta(\alpha_1,\beta_1)$, $Y \sim Beta(\alpha_2,\beta_2)$, and $Z = X/Y$.

Recall $X, Y$ are supported on $(0,1)$, so $z > 0$.

I've computed several $pdf$'s of the distribution of $Z$ (for varying Beta's) using a formula from a paper I found and paid for online, and have discovered to my dismay that the median of $Z$ is $1$.

I would love to submit my code but don't want to give away this formula because it costs \$48, but let's just say I am very sure there are no errors in it. For one thing, the area under the curve on $(0,\infty)$ is approximately $1$ (within 1e-8 according to Python's scipy.integrate.quad function) when I test several values for $\alpha_i,\beta_i$.

My question is: Is this correct? Expected? Obvious even? Possibly obvious from the [hidden] formula which I'd assume most academics have access to?

*Note: The reason this is surprising is because while the mean of the distribution behaves as one might expect: $\mathbb{E}X_1/\mathbb{E}Y_1 \leq \mathbb{E}X_2/\mathbb{E}Y_2 \implies \mathbb{E}Z_1 \leq \mathbb{E}Z_2$, the median does not seem to budge.

Happy to provide screenshots if anyone is interested.

  • 1
    $\begingroup$ Formulas are not secrets. If you want this question answered, then please be clear and state the formula. $\endgroup$
    – whuber
    Jul 17, 2015 at 10:18
  • 1
    $\begingroup$ I don't believe the claim in your question; I expect there's some omitted detail. $\endgroup$
    – Glen_b
    Jul 17, 2015 at 10:39
  • $\begingroup$ It's not hard to show that the median is a differentiable function of the four parameters with everywhere nonzero gradient. Consequently, the Implicit Function Theorem implies the set of parameters for which $Z$ has median $1$ is a codimension-one submanifold of $(0,\infty)^4$. Consequently, it is almost never the case that the median of $Z$ is $1$. Where you write about the "area under the curve is approximately $1$," it appears you have rediscovered the fact that the total probability of any random variable must be unity. $\endgroup$
    – whuber
    Jul 17, 2015 at 12:18
  • $\begingroup$ @whuber I will try to respond in more detail a bit later today, but for now will clarify that when I stated above the "the area under the curve is 1" was nothing to do with rediscovering the first axioms of what a probability measure was, but rather I was using this to spot check the formula for the pdf. I appreciate the vote of confidence though. $\endgroup$ Jul 17, 2015 at 14:56
  • $\begingroup$ Thank you for that clarification--I certainly was wondering what that remark in your question had to do with the median! That kind of calculation is indeed a smart way of checking a numerical integration routine. It still would be nice to see a specific example of a (nontrivial) quartet of parameters for which your calculation indicates the median is $1$. $\endgroup$
    – whuber
    Jul 17, 2015 at 15:57

2 Answers 2


Without providing details and the precise meaning, the random variable $Y$ goes to $0$ when $\beta_2 \to \infty$ and $X/Y$ goes to $\infty$. Hence the median of $X/Y$ should go to $\infty$ too, and it can't be always $1$.

There is a case in which your statement is easily seen to be true. The median is $1$ means $\Pr(X/Y>1)=\frac12$ or in other words $\Pr(X>Y)=\frac12$. Then the statement is true when $X$ and $Y$ have the same distributions ($\alpha_1=\alpha_2$ and $\beta_1=\beta_2$), because of symmetry (thus a possible error in your 48\$ code is that it always sets $\alpha_1=\alpha_2$ and $\beta_1=\beta_2$).

  • 1
    $\begingroup$ I needed to sleep on this and went and saw my code was listing the same parameters accidentally. $\endgroup$ Jul 17, 2015 at 15:09

As I mentioned in comments, I don't believe the claim in your question (that the median of the ratio of two beta variates is 1); I expect there's some omitted detail.

Here's two such ratios, a Beta(10,1)/Beta(1,10) and Beta(1,10)/Beta(10,1) -- they have very different medians, neither anywhere near 1.

enter image description here

(R code)

  • $\begingroup$ Hi Glen_b, what are you using to generate this. Where do the functions rbeta, plot, ecdf, lines, median, and abline come from? $\endgroup$ Jul 27, 2015 at 18:18
  • $\begingroup$ Also,, how do we know that the ratio you computed assumes independence of the random variables? $\endgroup$ Jul 27, 2015 at 18:20
  • $\begingroup$ Sorry, I should have said that's R. Those are all R functions. Variates are generated independently* by default ... you have to make them dependent. *(more strictly, pseudorandom numbers are not truly perfectly independent, but they're constructed in such a way that make them behave for essentially any purpose like this as if they were independent; they'll be as independent as scipy's random generation will be) $\endgroup$
    – Glen_b
    Jul 27, 2015 at 18:55
  • $\begingroup$ Thanks -- I'm trying to do the same thing in Python but having some trouble.... will figure it out! $\endgroup$ Jul 27, 2015 at 20:41
  • $\begingroup$ the essential steps of my algorithm were 1. generate $n$ x-values from a beta (skewed left) 2. generate $n$ y-values from a beta (skewed right). 3. Compute the ratios ($U_i=X_i/Y_i$) and find the median, (and plot). I also computed $V_i=Y_i/X_i$ to get the distribution of another ratio. $X_i$ and $Y_i$ will be effectively independent, as will $X_i$ and $X_j$ (and similarly for $Y$). So now $U_i$ and $U_{j\,\{j\neq i\}}$ should be independent as well. (While $U_i$ and $V_i$ will be dependent, that doesn't really impact what we're checking for here.) $\endgroup$
    – Glen_b
    Jul 28, 2015 at 0:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.