# If $X \sim$ Beta$(a,b)$, what is the distribution of $Y=\max \{X,1-X \}$?

I have a bunch of 2x2 hermitian matrices with eigenvalues $X, X-1$ that by definition sum to 1. I'd like to prove that for the distribution $X \sim$ Beta$(a,b)$, $a=b$ (i.e. there is no bias, or if there is some measure of bias like $|a-b|$), but as the direction of bias can change even within the sample, I would need to prove this based on $Y=\max \{X,1-X \}$ (i.e. the maximum eigenvalue from something like numpy.linalg.eigh)

It seems from Monte Carlo simulations that $Y \sim$ Beta4$(a_1,b_1,.5, 1)$ and I can try to regress $a_1,b_1 \sim f(a,b)$ based on that, but I was wondering if there was some closed form and it's just my google-fu that is failing.

If $X \sim \text{Beta}(a,b)$ with pdf $f(x)$:

Then, the cdf of $Y = \text{max}(X, 1-X)$, i.e. $P\big[\text{max}(X, 1-X) <y \big]$ is:

... where I am using the Prob function from mathStatica/Mathematica to automate the nitty-gritties. Differentiating the cdf wrt $y$ yields the pdf of $Y$, as say $g(y)$:

$$g(y) = \frac{y^a (1-y)^b + y^b(1-y)^a }{\left(y-y^2\right) B(a,b)} \quad \text{ for } \quad \frac12 <y < 1$$

The following diagram illustrates some sample pdf plots when parameter $a=2$ and $b$ varies:

• And here I was assuming it was another beta distribution and didn't ask for a parameter estimation of $(a,b)$ based on $Y$. I'll go see if I can work it out myself and maybe come back with another question. Thanks! – Daniel F Aug 16 '17 at 8:57

Suppose $X\sim Beta(a,b)$, which has density $$f(x) = \frac{x^{a-1}(1-x)^{b-1}}{B(a,b)},$$ on the domain $(0,1)$, where $B(a,b)$ is the normalising constant (Beta function).

Now, the quantity of interest $Y:=\max\{X,1-X\}\le t$ if and only if $1-t \le X \le t$ (for $1/2 \le t \le 1$), i.e. $$\mathbb{P}(Y \le t) = \int_{1-t}^t f(x) dx.$$

Differentiating this (just apply the chain rule) reveals $Y$ has density $$f(1-t) + f(t)$$ on $(1/2,1)$, i.e. $Y$ is a mixture of Beta distributions restricted to $(1/2,1)$ with the parameters flipped.

[Edit1: I see @wolfies beat me with a similar answer but I started and think it was worth pointing out the structure of the density]

[Edit2: N.b. argument above applies for any density $f$ on $(0,1)$ (although you won't always be able to just flip the parameters .]