2
$\begingroup$

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?

$\endgroup$
3
  • 2
    $\begingroup$ 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. $\endgroup$
    – flinty
    Mar 31, 2021 at 21:56
  • $\begingroup$ 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? $\endgroup$
    – Igor Yegin
    Mar 31, 2021 at 22:03
  • $\begingroup$ 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). $\endgroup$
    – flinty
    Apr 1, 2021 at 0:33

1 Answer 1

2
$\begingroup$

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).

$\endgroup$
1

Not the answer you're looking for? Browse other questions tagged or ask your own question.