Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Random vector generating - help!

  1. Jan 14, 2008 #1


    User Avatar


    I have to generate a random vector |Q>, which has the following form:

    |Q>=a*(1,0)+b*(0,1), where |a*a|+|b*b|=1 and (...,...) is a 2 dimensional column vector.

    This is a linear superposition of two vectors simply and the values of the vectors change between [0,1] randomly.

    I think, I schould use Monte Carlo simulation method...

    Please, if you have a source code (in C++), send me... this is very important!
  2. jcsd
  3. Jan 15, 2008 #2
    Monte Carlo ?!

    Well, I would first generate a random number , lets say R in [0.0 , 1.0] interval.
    Then I would evaluate X = 2Pi * R , and
    a = sin X
    b = cos X
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Random vector generating Date
Is it all in the angle? Jan 3, 2018
C/++/# How to check if a list of numbers is random? Sep 13, 2017
JApplet: Random Circles Feb 17, 2017
Random generated doubles: can I get a number more than once? May 3, 2016
Random walk Jan 30, 2016