This is an old version, view current version.

## 11.3 Transforming to unconstrained parameters

Stan (inverse) transforms arbitrary points in $$\mathbb{R}^{K+1}$$ to points in $$S^K$$ using the auxiliary variable approach of Marsaglia (1972). A point $$y \in \mathbb{R}^K$$ is transformed to a point $$x \in S^{K-1}$$ by $x = \frac{y}{\sqrt{y^{\top} y}}.$

The problem with this mapping is that it’s many to one; any point lying on a vector out of the origin is projected to the same point on the surface of the sphere. Marsaglia (1972) introduced an auxiliary variable interpretation of this mapping that provides the desired properties of uniformity; the reference manual contains the precise definitions used in the chapter on constrained parameter transforms.

#### Warning: undefined at zero!

The above mapping from $$\mathbb{R}^n$$ to $$S^n$$ is not defined at zero. While this point outcome has measure zero during sampling, and may thus be ignored, it is the default initialization point and thus unit vector parameters cannot be initialized at zero. A simple workaround is to initialize from a small interval around zero, which is an option built into all of the Stan interfaces.

### References

Marsaglia, George. 1972. “Choosing a Point from the Surface of a Sphere.” The Annals of Mathematical Statistics 43 (2): 645–46.