# Combined distribution of beta and uniform variables

Given

$$X \sim \text{Beta}(\alpha,\beta)$$ (where $\alpha=\beta$, if that helps) and

$$\theta \sim \text{Uniform}(0, \pi/2).$$

I'm trying to find a formula for $P(Y)$ (or even the cdf) of

$$Y = X + (1-2X)\cos(\theta)$$

on the domain $(0,1)$.

I know from here that given $C = \cos(\theta),$ its PDF is

$$P(C) = \frac{2}{\pi\sqrt{1-C^2}}$$

and of course the pdf of a beta distribution is

$$P(X) = \frac{X^{\alpha-1}(1-X)^{\beta-1}}{\mathrm{Beta}(\alpha, \beta)}.$$

But combining them is getting beyond my skills as an engineer.

EDIT: As it seems a closed form is not possible for this, could someone please show me how to formulate the integral to calculate this sort of PDF? There may be some way I can reformulate the problem to be more solution-friendly if I could wrap my head around how compound distributions of this type are built mathematically.

• I can obtain analytic solutions for the PDF when $\alpha=\beta$ are integral, but they are messy and get exponentially messier as $\alpha$ grows, suggesting there won't be any nice formula. Therefore they would be of little use for analysis. If you just need the distribution for particular $\alpha,\beta$ then numerical integration or even simulation will work well. If you need to analyze this distribution to obtain general properties, then you will have to work with the integrals without directly evaluating them.
– whuber
Commented Jan 18, 2018 at 15:26
• An integral solution would be worth an answer for me, unless someone else has some brilliant closed form, whether it's for $\alpha = \beta$ or not. I'm also just interested in the process for formulating the integral. Commented Jan 19, 2018 at 5:57

There is no closed form for the density. Its integral form can be obtained as follows. If we condition on $$X=x$$ we have $$Y = x + (1-2x) C$$ where $$C$$ ranges over the unit interval. The support under this condition is:

$$\text{supp}(Y|X=x) = \begin{cases} [x,1-x] & & & \text{for } 0 \leqslant x < \tfrac{1}{2}, \\[6pt] [1-x,x] & & & \text{for } \tfrac{1}{2} < x \leqslant 1. \\[6pt] \end{cases}$$

(We can ignore the case where $$x=\tfrac{1}{2}$$ since this occurs with probability zero.) Over this support we have the conditional density:

\begin{aligned} p_{Y|X}(y|x) &= \frac{1}{|1-2x|} \cdot p_C \bigg( \frac{y-x}{1-2x} \bigg) \\[6pt] &= \frac{1}{|1-2x|} \cdot \frac{2}{\pi} \bigg( 1 - \bigg( \frac{y-x}{1-2x} \bigg)^2 \bigg)^{-1/2} \\[6pt] &= \frac{1}{|1-2x|} \cdot \frac{2}{\pi} \bigg( \frac{(1-2x)^2 - (y-x)^2}{(1-2x)^2} \bigg)^{-1/2} \\[6pt] &= \frac{1}{|1-2x|} \cdot \frac{2}{\pi} \bigg( \frac{(1-4x+4x^2) - (y^2-2xy+x^2)}{(1-2x)^2} \bigg)^{-1/2} \\[6pt] &= \frac{1}{|1-2x|} \cdot \frac{2}{\pi} \bigg( \frac{1 - 4x + 3x^2 + 2xy - y^2}{(1-2x)^2} \bigg)^{-1/2} \\[6pt] &= \frac{1}{|1-2x|} \cdot \frac{2}{\pi} \cdot \frac{|1-2x|}{\sqrt{1 - 4x + 3x^2 + 2xy - y^2}} \\[6pt] &= \frac{2}{\pi} \cdot \frac{1}{\sqrt{1 - 4x + 3x^2 + 2xy - y^2}}. \\[6pt] \end{aligned}

Inverting the support we have $$\text{supp}(X|Y=y) = [0,\min(y,1-y)] \cap [\max(y,1-y),1]$$. Thus, applying the law of total probability then gives you:

\begin{aligned} p_Y(y) &= \int \limits_0^1 p_{Y|X}(y|x) p_X(x) \ dx \\[6pt] &= \int \limits_0^{\min(y,1-y)} p_{Y|X}(y|x) p_X(x) \ dx + \int \limits_{\max(y,1-y)}^1 p_{Y|X}(y|x) p_X(x) \ dx \\[6pt] &= \frac{2}{\pi} \frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha) \Gamma(\beta)} \Bigg[ \quad \int \limits_0^{\min(y,1-y)} \frac{x^{\alpha-1} (1-x)^{\beta-1}}{\sqrt{1 - 4x + 3x^2 + 2xy - y^2}} \ dx \\ &\quad \quad \quad \quad \quad \quad \quad \quad + \int \limits_{\max(y,1-y)}^1 \frac{x^{\alpha-1} (1-x)^{\beta-1}}{\sqrt{1 - 4x + 3x^2 + 2xy - y^2}} \ dx \Bigg]. \\[6pt] \end{aligned}

There is no closed form for this integral so it must be evaluated using numerical methods.

• Man I wish I'd had all this when I still had my head wrapped around this problem. I'm going to have to remember what the heck I was even asking at this point, but I remember it was something important at the time.. Thanks for your efforts! Commented May 25, 2020 at 10:36
• I have edited the answer to add the supports explicity, since the conditional density is zero outside of this range. Please have a look at the edited answer.
– Ben
Commented May 25, 2020 at 11:45

First of all note that given the support of $$\theta$$, the function $$\theta\to\cos(\theta)=:C$$ is a bijection. So once you fix $$Y=y,X=x$$, your variable $$C$$ has value $$\frac{y-x}{1-2x}$$ and there is a unique $$\theta$$ giving such value of $$C$$.

Given $$Y:=X+(1-2X)C$$ you can see that the support of $$Y$$ given $$X=x$$ is $$[1-x,1+x]$$ (since $$X>0$$ and $$C\in[0,1]$$). Conversely, fixing $$Y=y$$,

$$X\in\begin{cases}[1-y,1+y]&\text{if y>0}\\ [1+y,1-y]&\text{if y<0}\end{cases}$$

So

$$p_Y(y)=\begin{cases}\int_{1-y}^{1+y}p_X(x)p_C\left(\frac{y-x}{1-2x}\right)dx&\text{if y>0}\\ \int_{1+y}^{1-y}p_X(x)p_C\left(\frac{y-x}{1-2x}\right)dx&\text{if y<0}\end{cases}$$

• Thanks for the clarification! Commented May 25, 2020 at 10:37