# Simplex transform an hyperspherical cooridnates

**URL:** <https://discourse.mc-stan.org/t/simplex-transform-an-hyperspherical-cooridnates/30021>\
**Category:** Modeling\
**Created:** [January 11, 2023, 7:53am UTC](https://discourse.mc-stan.org/t/simplex-transform-an-hyperspherical-cooridnates/30021 "2023-01-11T07:53:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel-trejobanos](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/daniel-trejobanos/32/7166_2.png) [@daniel-trejobanos](https://discourse.mc-stan.org/u/daniel-trejobanos)\
**Post date:** [January 11, 2023, 7:53am UTC](https://discourse.mc-stan.org/t/simplex-transform-an-hyperspherical-cooridnates/30021/1 "2023-01-11T07:53:08Z")

</div>

Dear all,

I have a very simple and possibly dumb question. In the stan documentation you provide a stick breaking construction of the unconstrained simplex. This solution is based on the logit function.

In the footnote you cite @betanalpha paper on “cruising the simplex”. Now, in that paper everything is in hyperspherical coordinates, but it is claimed to be equivalent to the logit construction.

I am sad to admit I cannot see how both constructions are equivalent, can someone please help me figure this out?

Thank you and best regards.

---

<div class="post-metadata">

**Author:** ![spinkney](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@spinkney](https://discourse.mc-stan.org/u/spinkney)\
**Post date:** [January 11, 2023, 1:38pm UTC](https://discourse.mc-stan.org/t/simplex-transform-an-hyperspherical-cooridnates/30021/2 "2023-01-11T13:38:14Z")

</div>

Equivalent in the sense that they both lead to uniform distributed simplexes.

@mjhajharia is working on a paper that shows a bunch of different simplex transforms. In fact, there are infinitely many.

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [January 11, 2023, 5:47pm UTC](https://discourse.mc-stan.org/t/simplex-transform-an-hyperspherical-cooridnates/30021/3 "2023-01-11T17:47:09Z")

</div>

We should make that clearer in the doc. I created a doc issue to fix it:

> <https://github.com/stan-dev/docs/issues/613>
>
> \#### Summary:
> 
> The reference manual says that the hyperspherical and stick bre…aking constructions are the same, but we should qualify that to say that they're only the same in the sense that both produce uniform distributions over simplexes.
> 
> 
> \#### Additional Information:
> 
> See https://discourse.mc-stan.org/t/simplex-transform-an-hyperspherical-cooridnates/30021
> 
> \#### Current Version:
> v2.18.0

---

<div class="post-metadata">

**Author:** ![daniel-trejobanos](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/daniel-trejobanos/32/7166_2.png) [@daniel-trejobanos](https://discourse.mc-stan.org/u/daniel-trejobanos)\
**Post date:** [January 12, 2023, 11:58am UTC](https://discourse.mc-stan.org/t/simplex-transform-an-hyperspherical-cooridnates/30021/4 "2023-01-12T11:58:58Z")

</div>

Cool, I am interested, pleas @mjhajharia let me know when this is out.

---

<div class="post-metadata">

**Author:** ![betanalpha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/betanalpha/32/4_2.png) [@betanalpha](https://discourse.mc-stan.org/u/betanalpha)\
**Post date:** [January 17, 2023, 4:07pm UTC](https://discourse.mc-stan.org/t/simplex-transform-an-hyperspherical-cooridnates/30021/5 "2023-01-17T16:07:33Z")

</div>

The key result connecting the two is the first equation on page 2, second column. That is literally stick breaking for the intermediate variables z\_i = \sin^{2} \theta\_i; that said technically the z\_i are the complementary proportions used in the stick breaking, so 1 - z\_i is the proportion allocated to the $i$th element of the simplex and z\_i is the proportion that remains. One can equivalently take v\_i = 1 - z\_i.

The z\_i are constrained to the unit interval but taking a logit completely unconstrains them,

w\_i = \text{logit} z\_i = \text{logit} ( \sin^{2} (\theta\_i) ) \in (-\infty, \infty).

Working the other way one can start with the I - 1 unconstrained, real-valued variables w\_i and then construct the z\_i,

z\_i = \text{logistic} \, w\_i

and then use those as incremental complementary proportions,

x\_i = (1 - z\_i) \prod\_{i' = 1}^{i - 1} z\_i'.

Equivalently one can add use incremental proportions directly with

v\_i = 1 - \text{logistic} \, w\_i

and then use those as incremental complementary proportions,

x\_i = v\_i \prod\_{i' = 1}^{i - 1} (1 - v\_i').

Note that the “Cruising the Simplex” paper works with the hyperspherical parameters directly and doesn’t actually unconstrain them. The freedom in how to unconstrain them can be used to generate a transformation exactly equivalent to what is used in Stan or something complementary to what is used in Stan. This is also assuming that the ordering of the variables is fixed which is another degree of freedom in both methods.

I’ve mentioned this a few times in other threads but let me mention again that the freedom in constraining/unconstraining transformations is a bit overblown. Any two bijective transformations between a constrained space X and an unconstrained space Y are related by another bijection on Y (i.e. a reparameterization of Y). More formally if \phi\_1 : X \rightarrow \mathbb{R} and \phi\_2 : X \rightarrow \mathbb{R} then \phi\_1 = \psi \circ \phi\_2 where \psi : \mathbb{R} \rightarrow \mathbb{R}.

The question of which transformation is “best” is equivalent to asking which parameterization of the unconstrained space is “best” which is depends on the target distribution and is practically intractable.
