Skip to content

Commit

Permalink
Document new random number methods
Browse files Browse the repository at this point in the history
  • Loading branch information
d-torrance committed Sep 20, 2024
1 parent 54ca6ec commit 3265493
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions M2/Macaulay2/packages/Macaulay2Doc/functions/random-doc.m2
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,27 @@ Node
(random, ZZ)
(random, RR, RR)
(random, RR)
(random, CC)
(random, CC, CC)
(random, CC, RR)
(random, Number)
(random, Number, Number)
(random, QQ)
(random, QQ, QQ)
(random, QQ, ZZ)
(random, RR, CC)
(random, ZZ, QQ)
Headline
get a random integer or real number
get a random number
Synopsis
Usage
random(low, high)
random high
Inputs
low:{ZZ,RR}
high:{ZZ,RR}
low:Number
high:Number
Outputs
:ZZ
a random integer or real number of the same @TO precision@
:Number -- a random number
Description
Text
If only @TT "high"@ is given, the output will be in the range @TT "[0, high)"@.
Expand All @@ -58,6 +67,20 @@ Node
tally apply(100, i -> random(10,15))
random(10.,20.)
random(10p100,20p100)
Text
If the inputs are rational, then the output will be rounded to the
nearest rational number with denominator bounded by the number given
in the @TO Height@ option.
Example
apply(10, i -> random(-5_QQ, 5_QQ, Height => 5))
Text
If the inputs are complex, then the output will be a complex number whose
real part is drawn from the interval bounded by the real parts of the
inputs and whose imaginary part is drawn from the interval bounded by the
imaginary parts of the inputs.
Example
random(-1 + ii)
random(1 + 3*ii, 2 + 4*ii)
SeeAlso
setRandomSeed

Expand Down

0 comments on commit 3265493

Please sign in to comment.