# Normal distributed rotation matrix in 3D

How can I compute normally distributed 3D rotation matrices with Mathematica?

For 2D matrices I would sample a normal distributed angle and directly create a rotation matrix with:

normalRotation2[s_] := RotationMatrix[RandomVariate[NormalDistribution[0, s]]]


This has some kind of problems because the two tails of the distribution overlap at the far end due to the finite "size" of SO(2). I am not quite sure what the correct definition of normal distribution would be here... If there isn't any, let's use some next best concept like in normalRot2.

Now the question is how to do this in 3D?

Edit: For my purposes it would be enough to have an isotropic normal distribution.

-

## migrated from mathematica.stackexchange.comAug 12 '13 at 7:55

This question came from our site for users of Mathematica.

are you facing trouble with finding a NormalDistribution that generates 3D data ? – Rorschach Aug 11 '13 at 15:50
Is the primary question about mathematics, and secondarily about how to implement it in Mathematica? Does isotropic mean the axis is equally likely to point in any direction? If so, then this might help picking an axis. If you want uniform random rotations, then see this or this. By "normal" do you mean that the angle of rotation is normally distributed (mean = 0, s.d. = s)? – Michael E2 Aug 11 '13 at 19:03
What do you want to use this for? Because there are definitely cases when the wrap-around effect of the tails of the normal distribution for the periodic angle domain is a desired and needed effect. The fact that you write 'this has some problems' sounds like you actually want to do something else. You could e.g. use another distribution that decays to zero at the far end ($\theta=\pm\pi$). – Thies Heidecke Aug 11 '13 at 20:59
@Thies: I am using small standard deviations, so I do not care about the wrap-around. But thank you for the link, that was interesting. – Danvil Aug 14 '13 at 12:40
@E2: Both as I am usually prototyping with Mathematica before going to C++. With isotropic I wanted to say, that the normal distribution should treat all rotation directions equally. By "normal" I mean normally distributed -- so not uniform distributed or a purely random rotation. – Danvil Aug 14 '13 at 12:41

q = normalize(1, N(0,s), N(0,s), N(0,s))

with N(0,s) the Gaussian normal distribution with zero mean and standard deviation s generates an approximativly normally distributed rotation for small s.
Sounds like a good idea. You'll want to normalize $q$ to a unit quaternion so that it represents a rotation. – Rahul Aug 16 '13 at 19:45