4
$\begingroup$

I want to plot a Dirichlet distribution $\operatorname{Dir}(\alpha), \alpha=[\alpha_1, \alpha_2, \ldots,\alpha_n]$. However, when I google it, almost all of the results consider 3 targets ($n=3$), and the distribution can be visualized by a triangle (e.g. Dirichlet distribution from Wikipedia).

What if I have 4 ($n=4$) or 5 ($n=5$) targets? Will the visualization be rectangle or pentagon?

To obtain some toy data, we can do

from scipy.stats import dirichlet
import numpy as np

n_samples = 100
alpha = np.array([0.4, 5, 15, 3, 2])
toy_data = dirichlet.rvs(alpha, size=n_samples) #shape (100, 5)
$\endgroup$

1 Answer 1

7
$\begingroup$

A Dirichlet distribution is a distribution over a simplex.

A simplex is a lower-dimensional ($n-1)$ subspace of an $n$-dimensional space. With two targets, the simplex is a line. With three targets, it’s a triangle. In four, it’s a tetrahedron (not a square)…and so on.

The reason you don’t see 4-target examples is because it’s hard to display probability density on the 3D structure. The reason you don’t see 5-target or higher is that we’re bad at visualizing 4D spaces. Our visual system (and indeed, our entire grip on reality) is centered on 3D space. Trying to visualize more than that is the challenge of Abbott’s famous book Flatland.

$\endgroup$
4
  • 2
    $\begingroup$ I've always wanted to write some code for visualizing 4-element compositional data/distributions in a tetrahedon, even though it would be more cool than useful ... I wonder if there's an analog of pairs plots for higher-order compositional data ... ?? $\endgroup$
    – Ben Bolker
    Commented Jun 20, 2021 at 3:26
  • $\begingroup$ Thanks for your explanation. It makes sense to me. If I have n=5, do you think it is reasonable to use the vertex figure (which is a pentagon) of 4-simplex to visualize the Dirichlet distribution? Or do you have any idea for visualizing 4-simplex? Thanks! $\endgroup$ Commented Jun 21, 2021 at 21:27
  • $\begingroup$ @GuanjieHuang, if you can provide an example dataset, people could play with it, & we could see what people might come up with. Personally, I'm dying to see Ben's visualization... $\endgroup$ Commented Jun 22, 2021 at 18:28
  • $\begingroup$ @gung-ReinstateMonica Thanks! I also pretty want to see Ben's plot. BTW, I add some toy data to my question. So, each toy data will be 5D. Please feel free to let me know if you have any thought about it! Thanks $\endgroup$ Commented Jun 23, 2021 at 1:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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