# Get a random number generator for various cases?

Posted 7 months ago
657 Views
|
2 Replies
|
1 Total Likes
|
 Hi , I am very new to mathematica ,please can any one help me to generate random numbers I have tried as follows for {1,-1} case RandomReal[{1, -1}, 10] My output is {-0.572419, -0.713784, 0.589145, -0.309582, 0.678755, -0.496263, -0.0828302, -0.725051, -0.290749, -0.00272715} But I need random number generator for {2,-2},{3,-3} at one shot.I tried for above one as follows, but no use. RandomReal [ [{1, -1},{2,-2},{3,-3}],10] Please help me to resolve the issue.
2 Replies
Sort By:
Posted 7 months ago
 Something like this? Transpose[{1, 2, 3} RandomReal[{-1, 1}, {3, 10}]] (* Out[373]= {{0.981734293226, 0.684303054, -0.437793709387}, {-0.0362668999938, -1.20283477061, \ -1.33978431487}, {0.375630986245, 0.592477784197, -1.13340532819}, {-0.722525173953, -0.659695292216, \ -2.70412310576}, {0.138754748527, 0.042501729885, 0.280926778119}, {0.970810465664, 1.22555900094, -1.23595811685}, {0.246593090112, -0.982459686448, 2.91243740985}, {-0.800383383347, 1.24284223826, 1.69913760441}, {0.442353700026, 0.932816130511, 1.63156023223}, {-0.82593776151, 0.0130059873043, 0.307173349828}} *) 
 Using random integers and the three ranges {-1,1}, {-3,3}, {-5,5}: TableForm[ Table[RandomInteger[{i, -i}, 10], {i, {1, 3, 5}}], TableAlignments -> Right ]