I want to generate $1,000,000$ $3\times 1$ matrices, where the range of random number in each element of the matrix is different.

n = 1000000;
ParallelTable[{RandomReal[{(-4 π)/(3 Sqrt[3]), (4 π)/(
  3 Sqrt[3])}], RandomReal[{(-2 π)/(3), (2 π)/(3)}],
 RandomReal[{-π, π}]}, n]; // AbsoluteTiming

Can someone suggest a much faster/elegant way, if any, to generate this? Also, if you think this will not work, can you explain?


1 Answer 1


You could do:

    RandomReal[{-1, 1}, {3, 10^6}] N@{4 π/(3 Sqrt[3]), 2 π/3, π}
]; //AbsoluteTiming

{0.032924, Null}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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