I have a collection of points that lie in the unit simplex in 4 dimensions. That is, each point is a vector of four non-negative real numbers that sum to 1. (They are probability distributions.)
This simplex in 4 dimensions is equivalent to a three dimensional tetrahedron. I would like to make a 3D plot of my points, each one plotted inside a regular tetrahedron, but I can't seem to work out the formula to transform my four-dimensional points into three-dimensional space in the correct way.
That is, I'm looking for a set of (presumably linear) equations that map the vectors $(1,0,0,0)$, $(0,1,0,0)$, $(0,0,1,0)$ and $(0,0,0,1)$ to the four corners of a regular tetrahedron, and the vector $(\frac{1}{4},\frac{1}{4},\frac{1}{4},\frac{1}{4})$ to its centre. (The position, scale and rotation of the tetrahedron don't matter.) Any insights into how to construct this mapping would be most appreciated.
This is a self-answer for the sake of others, generated from the helpful hints in the comments.
Ethan Bolker wrote:
and Rahul wrote:
This is straightforward once you realise it. For future visitors who just want a quick solution, here's my first attempt in Python, which is much simpler than what I was trying before, but puts the tetrahedron in a strange orientation, with an edge facing downwards:
I prefer to draw it as a triangular pyramid, with a face pointing downward. After some further hints from this page, here's some code that does that:
(If you're worried about efficiency you can remove the terms where something gets multiplied by zero, as I just put those in to make the structure clear.)