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
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook