# How to calculate the PDF of the 'difference' between two Beta distributions?

$$\mathrm{Beta_A}(p; \alpha_A, \beta_A) = \frac{p^{\alpha_A-1}\,(1-p)^{\beta_A-1}}{\mathrm{B}(\alpha_A, \beta_A)}$$

$$\mathrm{Beta_B}(p; \alpha_B, \beta_B) = \frac{p^{\alpha_B-1}\,(1-p)^{\beta_B-1}}{{\mathrm{B}(\alpha_B, \beta_B)}}$$

where in the context of Bernoulli trials, $$\alpha$$ can be interpreted as $$1 + \mathrm{successes}$$ and $$\beta$$ can be interpreted as $$1 + \mathrm{fails}$$. $$\mathrm{B}$$ is the Beta function.

I then define the 'difference' between $$\mathrm{Beta_A}$$ and $$\mathrm{Beta_B}$$ as:

$$F(x; \alpha_A, \beta_A, \alpha_B, \beta_B) = \mathrm{Beta_A}(p) - \mathrm{Beta_B}(p)$$

Questions

• what is the PDF of $$F(x)$$?
• what family of probability density distributions does $$F(x)$$ belong to?

Example and illustration

For example for $$\alpha_A=3, \beta_A=9$$ (2 successes from 8 Bernoulli trials) and $$\alpha_A=1, \beta_A=5$$ (0 successes from 4 Bernoulli trials) the distribution of values that $$p$$ can take is: If I then take $$n$$ random values $$X_A \sim \mathrm{Beta_A}$$ and $$X_B \sim \mathrm{Beta_B}$$, and find the differences between each $$i^\mathrm{th}$$ element, $$X_{A,i} - X_{B,i}$$, and plot these $$n$$ differences in a histogram, I am essentially sampling $$F(x)$$ - the underlying distribution of $$\mathrm{Beta_A} - \mathrm{Beta_B}$$ which can only be defined for $$x \in [-1,+1]$$.

With $$n = 5 \times 10^7$$ random samples and bin widths of $$\Delta x = 0.004$$, $$F(x)$$ takes the following form: What is the PDF of $$F(x)$$?

Notes

• Do you mean a convolution? math.la.asu.edu/~jtaylor/teaching/Fall2010/STP421/lectures/… – Dave Nov 14 '19 at 12:32
• I guess I meant to follow the logic of the derivation but applied to subtraction instead of addition. I don’t think there would be that bound on $x$, though working through the calculus should reveal if there is. – Dave Nov 14 '19 at 13:15
• The notations are awfully confusing, as they make $F(x)$ look like the difference of two Beta densities. Furthermore, $x$ and $p$ are not explicitly related. – Xi'an Nov 14 '19 at 13:19
• There is an answer on maths.stackexchange. – Xi'an Nov 14 '19 at 13:20
• – kjetil b halvorsen Nov 14 '19 at 13:39