-
Notifications
You must be signed in to change notification settings - Fork 430
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
Sampling quaternion variables constrained to a manifold #408
Comments
You can reparameterize to sample in an unconstrained 4-D space, e.g.:
then normalize these to get your quaternions before evaluating your model:
You can check that these are uniformly distributed on your target manifold. In emcee, I would write this as: def logprob(theta):
# We're going to sample in the unconstrained space, then normalize those
# parameters
norm = np.sum(theta ** 2)
x, y, z, w = theta / np.sqrt(norm)
# Then, we need to put a prior on that space so that we can sample. As long
# as it's spherical, anything would be fine; let's use a standard normal
logprior = -0.5 * norm
# Use x, y, z, and w, which will now be correctly normalized)...
loglike = 0.0 # Some function fo x, y, z, and w
return logprior + loglike |
After second thoughts, I’m thinking my loglikelihood is problematic it seems to skew the distributions in a very unspherical way. I guess the procedure you suggested does indeed do what it should, I’m just not using it right in this simplified problem :) |
Hi,
I have a question that may or may not be outside the scope of emcee.
I am trying to replicate work found here using emcee: http://asa.scitation.org/doi/10.1121/1.5017840
This work tries to infer elastic constants as well as a 3D angle of rotation using Hamiltonian Monte Carlo.
To parametrize this rotation unambiguously, they avoid Euler angles and choose unit quaternions defined by four scalar values (x, y, z, w) which completely describe the rotation that is sought to best match experimental data.
I tried to define this problem using emcee but then realized that I am missing something important: the ability to constrain values given by the proposal distribution.
Concretely, if the proposal distribution generates 4 new values (x, y, z, w), they have to satisfy x^2 + y^2 + z^2 + w^2 = 1 to lie on the required manifold for rotations.
Browsing the documentation, I was wondering if it is possible to use the Move interface to achieve something like this?
Or do you see an alternative package I should move to?
Thank you for any pointers.
Regards,
Florian
The text was updated successfully, but these errors were encountered: