Message Boards Message Boards

0
|
4355 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Get a random number generator for various cases?

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.

POSTED BY: GABBAR JADAV
2 Replies
Posted 6 years ago

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
 ]

enter image description here

POSTED BY: Hans Milton

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}} *)
POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract