Macaulay2 » Documentation
Packages » Macaulay2Doc » combinatorics » random » random(ZZ,ZZ)
next | previous | forward | backward | up | index | toc

random(ZZ,ZZ) -- get a random integer or real number

Description

Synopsis

If only high is given, the output will be in the range [0, high).

i1 : random 57

o1 = 43
i2 : random 10^50

o2 = 27966429632588001730589592232989755722230769700437
i3 : tally apply(100, i -> random 7)

o3 = Tally{0 => 9 }
           1 => 16
           2 => 11
           3 => 15
           4 => 14
           5 => 11
           6 => 24

o3 : Tally
i4 : random 3.14

o4 = 2.00442043654275

o4 : RR (of precision 53)
i5 : random 3p200

o5 = 2.362050531245025823152580356155207457761196081817725396837539

o5 : RR (of precision 200)

If, in addition, low is given, the output will be in the range [low, high]

i6 : for i to 10 list random(100,200)

o6 = {195, 135, 192, 166, 106, 140, 103, 170, 125, 199, 160}

o6 : List
i7 : tally apply(100, i -> random(10,15))

o7 = Tally{10 => 20}
           11 => 17
           12 => 14
           13 => 12
           14 => 21
           15 => 16

o7 : Tally
i8 : random(10.,20.)

o8 = 10.75106240004187

o8 : RR (of precision 53)
i9 : random(10p100,20p100)

o9 = 17.03319064630373207472512821212

o9 : RR (of precision 100)

See also

Ways to use this method:

  • random(RR)
  • random(RR,RR)
  • random(ZZ)
  • random(ZZ,ZZ) -- get a random integer or real number

The source of this document is in Macaulay2Doc/functions/random-doc.m2:262:0.