# How to find sum of squares of data from a multivariate (Dirichlet) distribution? [closed]

Let $$X = Dirichlet(1,1,1)$$ be a tri-variate random variable with Dirichlet distribution with parameters all equal to 1. I need to find what $$X_1^2+X_2^2+X_3^2$$ will be.

I did TransformedDistribution[x^2+y^2+z^2, {x,y,z}\[Distributed]DirichletDistribution[{1,1,1}]], but it doesn't seem to do anything. What might be the problem?

• Do RandomVariate[DirichletDistribution[{1,1,1}]] and you'll see the problem -- it's two dimensional, not three. Look at the docs - it has k+1 parameters, where k is the dimensionality. If you add an extra one, the transformed distribution won't appear to do anything but you'll now be able to call RandomVariate and Mean on it to get statistics - I get mean of 3/10. Mar 31, 2021 at 21:56
• Oh, my bad, thank you! However, if I add another parameter and call PDF, the code runs extremely slow. Is PDF of TransformedDistribution supposed to be that slow? Mar 31, 2021 at 22:03
• Yes it gets very slow at higher dimensions, my guess is it comes from the difficult multidimensional integrals required to compute the normalizing constant for the PDF (so it integrates to 1). Apr 1, 2021 at 0:33

I think this may be what you were looking for originally:

dist =
TransformedDistribution[
x^2 + y^2 + (1 - x - y)^2,
{x, y} \[Distributed] DirichletDistribution[{1, 1, 1}]
]


where $$x+y+\underbrace{(1-x-y)}_{z}= 1$$.

You can then get the mean and variance (for example)

Mean[dist] --> 1/2
Variance[dist] --> 1/60


You can confirm these values by simulation.

Nevertheless, you are quite right that getting the PDF takes a bit of time

PDF[dist,w] // FullSimplify


and produces a relatively complicated expression (that I won't try to reproduce here).