Re: Random directions



Thanks Roger.
I am trying to solve this problem using unit vectors in 3D space and
I would like a uniform distribution. Essentially, I am trying to
generate synthetic crystal axes in real space.

That worked really well. Thanks alot!!

Roger Stafford wrote:


In article <ef3d2f4.-1@xxxxxxxxxxxxxxxxxxxxxxx>, "Jim Hnat"
<jhnat@xxxxxxxxx> wrote:

Dear Matlab users,
I am trying to generate randomly oriented vectors, knowing the
angle
between the random vector (RV) and a fixed vector (FV).
Essentially
this gives me a cone about the FV.
Because the RV is a fixed angle from the FV, trying to use the
rand()
funtion for one of the direction cosines of RV and solving for
the
other two is not possible.

How might I go about generating these random vectors?

Thanks
-Jim
-------------------------------------
I have a few questions here. First, are you talking about
three-element
vectors in three-dimensional space? I will assume here that that
is the
case. Second, what sort of random distribution on the cone do you
wish to
have? You probably want a uniform distribution of the angle
transversely
around the cone over a 2*pi span, but what is the distribution to
be along
the length of the cone? It can't be uniform since the length is
infinite. Also it can't be uniform over the surface area of the
cone
since that is infinite too. Perhaps you are only interested in
unit
length vectors? I will temporarily assume you want unit length
random
vectors.

Let 'alpha' be the specified angle between RV and FV. Use
matlab's
'null' function on the column vector FV to obtain two orthonormal
column
vectors which are also orthogonal to FV. Call them p and q.

x = null(FV.'); p = x(:,1); q = x(:,2); % Two orthonormal vectors
beta = 2*pi*rand; % Random transverse angle
RV = FV/norm(FV)*cos(alpha)+(p*sin(beta)+q*cos(beta))*sin(alpha);

If you don't want to be restricted to unit length vectors, then
generate
a random length, 'r', with whatever distribution you desire for the
length
and do:

RV = r*RV;

If you want more than three-element vectors, that is a deeper
problem.
I'll wait to hear from you about that.

Roger Stafford

.



Relevant Pages

  • Re: OT raibow
    ... Looking at the picture of ray ... and a0 the angle at the vertex of the cone. ... conjecture corresponds to distribution with density concentrated at ...
    (comp.lang.perl.misc)
  • Re: Random directions
    ... between the random vector and a fixed vector. ... Because the RV is a fixed angle from the FV, ... what sort of random distribution on the cone do you wish to ...
    (comp.soft-sys.matlab)
  • Re: HUP Fails Via Nonexistent Distributions 2: The Uniform Claim
    ... > Max Jammer's The Philosophy of Quantum Mechanics, Wiley: ... Also, the probability that q is in [L1, ... > The uniform probability distribution in mathematical ... the graph of a uniform distribution is a horizontal line ...
    (sci.physics)
  • Re: Stochastic Positioning of A Point in A 3D Gaussian Distribution
    ... uniform distributions into a geometrical pair x,y with Gaussian ... one PRNG number with uniform distribution into one number ... Numbers by a PRNG with uniform distribution can be trans- ... number generator, whether for uniform or Gaussian distributions. ...
    (comp.graphics.algorithms)
  • Re: Test of Independence
    ... > should represent two random digit sets (uniform distribution). ... I am looking for randomness and that they are independence ... - Does it matter if one is a lagged version of the other? ... > validate that it is distributed following a uniform distribution. ...
    (sci.stat.math)