Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

First consider vectors of unit length, say on the unit sphere. Now I want to give some magnitude to these vectors and I want the magnitude to be chosen from the normal distribution. In one dimension that is easy:


However, if my vector is arbitrarily pointed I cannot take from this distribution since I cannot have a negative magnitude.

The only way I can think of giving the vector a normal distribution of lengths is by using


which forces the randomly chosen quantity to be > 0. Does this seem like the proper procedure?

share|improve this question
Why not Normalize[] the vectors to have unit length, and then multiply the components with RandomReal[NormalDistribution[0,x]]? (I haven't posted as an answer since you make no mention of the distribution the vectors themselves are supposed to follow...) –  J. M. Feb 3 '12 at 2:57
@J.M The vectors orientations are distributed over some portion of the sphere (with azimuthal symmetry and symmetric around polar angle of 90). So I think the negative part of the vectors is accounted for already through the angle distribution and that's why I didn't use the full normal distribution. –  BeauGeste Feb 3 '12 at 3:05
From Mma documentation on RandomReal I would have thought that you needed RandomVariate[...]; but, to my surprise, RandomReal[NormalDistribution[0,1]] generates standard normal random numbers,i.e., RandomReal does accept distribution functions as the first argument:) –  kguler Feb 3 '12 at 3:16
@BeauGeste I did the calculation and realized the normal distribution of lengths and the normal distribution of coordinates are actually the same thing (assuming a spherically symmetric angular distribution), which is why I deleted my comment ;-) –  David Z Feb 3 '12 at 3:19

2 Answers 2

Technically, the normal distribution is defined on the real line, $\mathbb{R}$, but vector lengths are nonnegative numbers, elements of $\mathbb{R}_{0+}$. So you can't really have the lengths of your vectors satisfy a normal distribution. You have to choose a distribution for the lengths that has the correct domain, $\mathbb{R}_{0+}$.

One thing you can do, and my best guess at what you really want, is to use the restriction of the normal (or half-normal) distribution to the nonnegative numbers. That would be accomplished exactly like you said, by choosing the length from HalfNormalDistribution.

If the angular distribution of the vectors (the distribution of their directions) has reflection symmetry, in the sense that a vector is just as likely to point in any particular direction $\hat{n}$ as it is to point in the opposite direction $-\hat{n}$, then you actually can multiply the unit vectors you have by random numbers chosen from the full normal distribution. If the random number is negative, it will switch the direction of your vector, but since $P(\hat{n}) = P(-\hat{n})$, the probability of switching any one direction to the opposite direction is the same as the probability of switching the opposite direction to the original direction. Those two effects cancel out. If the angular distribution is not symmetric, however, then using the full normal distribution will have the effect of symmetrizing it, i.e. you'll wind up with a new distribution of directions $P'$ such that $P'(\hat{n}) = \frac{1}{2}\bigl(P(\hat{n}) + P(-\hat{n})\bigr)$.

share|improve this answer
thanks; had never seen the half-normal before was was wary of using it. That is a good point on the symmetry. The reason I am trying to make these vectors is that I start out with normal fields constrained in x-y plane; that is easy - can do normal distribution for x and y components. What I really want is to allow the plane the fields lie in to be distributed out of the x-y plane; the fields keep the same distribution wrt to their plane but not to the x-y plane. With your help, I think I now have the solution to describing these fields. –  BeauGeste Feb 3 '12 at 4:07
Ah, I see. For generating vectors randomly distributed in an arbitrary plane, you can still choose components $x$ and $y$ from a normal distribution, but instead of using $\hat{x} = (1,0,0)$ and $\hat{y} = (0,1,0)$ as your basis vectors, you use an orthonormal basis $\hat{a},\hat{b}$ for your plane, and form the final vector as $x\hat{a} + y\hat{b}$. That may be cleaner than choosing the magnitude from a half-normal distribution and whatever you're doing to get the directional distribution. –  David Z Feb 3 '12 at 5:41
Actually I tried that originally and ran into some numerical errors when using Gram-Schmidt process (the random vectors occasionally are near parallel). This may be a future question since I would like to check the accuracy of using the (Half)NormalDistribution method discussed in this present question –  BeauGeste Feb 3 '12 at 18:50
Huh, so how are you determining the plane in which you want these vectors to lie in the first place? –  David Z Feb 3 '12 at 18:54
I choose those two vectors randomly over a swath near the equator. –  BeauGeste Feb 3 '12 at 20:26

Theorem. This works pretty well:

randomVector := RandomVariate[NormalDistribution[], 3];

Proof. Create a large data set and display it for the fun of it.

points = Table[randomVector, {100000}];
Graphics3D[{PointSize[0], Point[points]}]

enter image description here

Statistics time! Histogram plus Maxwell distribution etc,

norms = Norm /@ points;
hlist = HistogramList[norms];
    Plot[\[Pi] Max[hlist[[2]]] r^2 PDF[NormalDistribution[], r], {r, 0, Max[hlist[[1]]]}, PlotStyle -> ColorData[1][2]]

enter image description here

Looks pretty good to me. $\square$

(David Zaslavsky's comment is of course still valid, thete's no normal distribution on $\mathbb R^+$.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.