-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hyperspherical parameterization of the simplex #41
Comments
Continuing further, if we let and its absolute Jacobian determinant is Finally, letting |
we could reference https://arxiv.org/pdf/1010.3436.pdf |
Ah, perfect! Yes, the transformations are identical. |
yes! sidenote: also because of some squashing that I did and the time when i wasn't merging PRs there were conflicts on all branches so I merged all the PRs and am fixing up that stuff now, if after an hour or so something's wrong let me know so I can figure out if I messed up something |
Okay, thanks for the heads up! |
As noted in an earlier e-mail, if$z$ is a unit vector of length $N$ , then squaring each element so $x_i = z_i^2$ gives us a point $x$ on the simplex. If all elements of $z$ are positive (i.e. $z$ is on the positive orthant of the hypersphere), then this map is bijective. So if we can generate unit vectors with positive elements, we can use that transform to also sample on the simplex.
As mentioned in #1, using
exp
to make each element positive in the end gives us the augmented softmax parameterization.We can do this as well with the hyperspherical transform, which is written
where$\phi_j$ is in $(0, 2\pi]$ when $j=N-1$ and $(0, \pi]$ otherwise.
The requirement that$z_i$ be positive for $i < N-1$ is satisfied by requiring $\phi_i \in (0, \pi/2]$ for all $i$ .
It turns out that the Jacobian determinant here is
I suspect due to the trigonometric functions, it may not be extremely efficient. However, all of these trigonometric functions are bijective over this range, so we can replace sines or cosines with numbers constrained to the interval$(0, 1)$ to get a new transform.
I'll shortly add Stan functions for both of these.
The text was updated successfully, but these errors were encountered: