# Distribution of distances to mean of symmetric beta distribution

I have a symmetric beta distribution and draw d samples $$x_i \sim Beta(a, a)$$ for some a. Now I want to know the distribution of $$\ell_2$$-distances of the sample vector $$(x_1, \dotsc, x_d)^T$$ to the mean $$(0.5, ..., 0.5)^T$$. This is somewhat akin to what the $$\chi$$-distribution does for a normal distribution.

I would be interested in just knowing the distribution but it would be a great bonus if you also now the CDF of it.

My current best approaches would be to approximate the beta distribution by a normal distribution or calculate the $$\ell_\infty$$-ball instead because in that case it can be reduced to a one-dimensional problem but I'm not really happy with these approximations.

• You can derive the CDF of any single $(x_i-1/2)^2.$ It is a simple transform of a (different) Beta distribution. There's no nice formula for the sum of independent values.
– whuber
Commented Oct 4, 2022 at 21:45
• @Jannis If numerical (rather than algebraic) answers suffice, you could look at convolution (e.g. via fast Fourier transforms, which should be able to get you to pretty accurate numeric approximations). For large n, there's a normal approximation via the CLT. It may also be possible to use something like a saddlepoint approximation, which could provide better accuracy. There's also simulation, which can be as accurate as you have patience for. Commented Oct 5, 2022 at 0:52

This should be considered an extended comment rather than an answer. I show a not-so-useful result for $$d=2$$ and then show how to construct the moment generating function for the square of the distance (and not the distance as requested).

CDF for $$d=2$$

Using a computer algebra system you can get explicit formulas of the cdf's and pdf's for $$n=2$$ (and maybe higher) and integer values of $$a$$. Here are some of those special case solutions using Mathematica:

n = 2;
a = 1;
dist = TransformedDistribution[Sqrt[Sum[(x[i] - 1/2)^2, {i, n}]],
Table[x[i] \[Distributed] BetaDistribution[a, a], {i, n}]];
cdf1 = CDF[dist, z]


n = 2;
a = 2;
dist = TransformedDistribution[Sqrt[Sum[(x[i] - 1/2)^2, {i, n}]],
Table[x[i] \[Distributed] BetaDistribution[a, a], {i, n}],
Assumptions -> a > 0];
cdf2 = FullSimplify[CDF[dist, z] /.
-I (Log[I - Sqrt[-1 + 4 z^2]] - Log[I + Sqrt[-1 + 4 z^2]]) -> 2 ArcTan[Sqrt[-1 + 4 z^2]]]


A graph of the cdf's for $$a=1, 2, 3$$ follows:

Moment generating function for the square of the distance

After playing around with constructing the moment generating with integer values of $$a$$ and getting results, I tried using rational numbers for $$a$$ and the pattern for the moment generating function became apparent. (Mathematica did not return results when either the symbol $$a$$ is given as the parameter or if a non-rational number is given but results were always returned when rational numbers were used for $$a$$.)

Following @whuber 's hint in the comments one can find the distribution of $$(x_i-1/2)^2$$:

dist = TransformedDistribution[(x - 1/2)^2, x \[Distributed] BetaDistribution[a, a],
Assumptions -> a > 0];


The moment generating function for that random variable with a specified value of $$a$$ is

mgf = MomentGeneratingFunction[dist /. a -> 17/16, t] // FullSimplify


$$\, _1F_1\left(\frac{1}{2};\frac{25}{16};\frac{t}{4}\right)$$

where $$\, _1F_1$$ is the Kummer confluent hypergeometric function. By looking at various rational values of $$a$$ the general form of the moment generating function for $$a=p/q$$ is

$$M(t)=\, _1F_1\left(\frac{1}{2};\frac{2 p+q}{2 q};\frac{t}{4}\right)$$

So this can be re-written as follows:

$$M(t)=\, _1F_1\left(\frac{1}{2};a+\frac{1}{2};\frac{t}{4}\right)$$

For the sum of $$d$$ independent random variables with the same value of $$a$$ the moment generating function is $$M(t)^d$$. We can find all of the desired moments:

mgf = Hypergeometric1F1[1/2, a + 1/2, t/4]

mean = D[mgf^d, t] /. t -> 0 // FullSimplify


$$\frac{d}{8 a+4}$$

variance = (D[mgf^d, {t, 2}] /. t -> 0) - mean^2 // FullSimplify


$$\frac{a d}{4 (2 a+1)^2 (2 a+3)}$$

The 3rd and 4th moments are a bit lengthier:

m3 = D[mgf^d, {t, 3}] /. t -> 0 // FullSimplify


$$\frac{d \left(4 a^2 (d+2) (d+4)+4 a (d+4) (4 d-1)+15 d^2\right)}{64 (2 a+1)^3 (2 a+3) (2 a+5)}$$

m4 = D[mgf^d, {t, 4}] /. t -> 0 // FullSimplify


$$\frac{d \left(96 a \left(8 a^3-20 a+3\right)+(2 a+3)^2 (2 a+5) (2 a+7) d^3+24 a (2 a+3) (2 a+5) (2 a+7) d^2+16 a (2 a+7) (a (22 a+31)-12) d\right)}{256 (2 a+1)^4 (2 a+3)^2 (2 a+5) (2 a+7)}$$

As a check consider some simulations with $$a=36/11$$ and $$d=7$$.

n = 1000000;  (* Sample size *)
d = 7;  (* Dimension *)
a = 36/11
SeedRandom[12345];
x = Total[(# - 1/2)^2] & /@ RandomVariate[BetaDistribution[a, a], {n, d}];
Mean[x]
(* 0.231805 *)
d/(4 + 8 a) // N
(* 0.231928 *)
Variance[x]
(* 0.0105387 *)
(a d)/(4 (1 + 2 a)^2 (3 + 2 a)) // N
(* 0.0105385 *)


This doesn't give you the cdf or pdf but maybe knowing the moments of the square of the distance can help you achieve your analysis objective.

A generalized gamma distribution with pdf

$$\frac{\gamma e^{-\left(\frac{z}{\beta }\right)^{\gamma }} \left(\frac{z}{\beta }\right)^{\alpha \gamma -1}}{\beta \Gamma (\alpha )}$$

for $$z>0$$ and 0 elsewhere seems to provide a reasonable fit.

sol = FindDistributionParameters[x, GammaDistribution[α, β, γ, 0],
{{α, 1.947}, {β, 0.1639}, {γ, 1.641}}]
(* {α -> 1.92386, β -> 0.165846, γ -> 1.65522} *)

Show[Histogram[x, "FreedmanDiaconis", "PDF"],
Plot[PDF[GammaDistribution[α, β, γ, 0] /. sol, z], {z, Min[x], Max[x]}]]


• Although you might get some formulas for $n\gt 2,$ they are next to useless for analysis because they will be presented in a piecewise manner with at least $n$ components.
– whuber
Commented Oct 6, 2022 at 14:15
• @whuber I should have stated that my "answer" was just an "extended comment" which was to show the complexity even for $d=2$ (and I will make that change later today). I disagree with "next to useless" in part because if the exact answer requires multiple components, then that's just what it is. Whether or not an approximation satisfies the need for the OP's analysis needs depends on the so far unstated needs.
– JimB
Commented Oct 6, 2022 at 15:59
• "Just what it is" overlooks the possibility of analysis, which means making estimates, approximations, asymptotic determinations, expansions in series, and many other useful activities that an increasingly complex exact expression denies to us.
– whuber
Commented Oct 6, 2022 at 17:14
• Rather than edit this again, I'll note that if the generalized gamma is a good fit for the square of the distance, then the square root of a generalized gamma might very well be a good fit for the distribution of the distance and there is an explicit function for both the pdf and cdf of that random variable.
– JimB
Commented Oct 7, 2022 at 16:55