RandomReal
Returns a random real number.
Syntax
-
RandomReal()
-
RandomReal(M)
-
M
is a real number
-
-
RandomReal(A, B)
-
A
andB
are real numbers
-
Description
-
RandomReal()
returns a random real number in[0, 1)
. -
RandomReal(M)
returns a random real number inM⋅[0, 1)
. -
RandomReal(A, B)
returns a random real number inA + (B − A)⋅[0, 1)
.
Examples
stats ≔ L ↦ '(min(L), mean(L), max(L))
custom function
stats(compute(RandomReal(), n, 1, 1000000))
3.03238630295⋅10^−6 0.499875858509 0.999997370411
stats(compute(RandomReal(10), n, 1, 1000000))
6.59609213471⋅10^−6 5.00291941674 9.99997504288
stats(compute(RandomReal(10, 20), n, 1, 1000000))
10.0000055297 14.9973888885 19.9999980279
stats(compute(RandomReal(0), n, 1, 1000000))
0 0 0
stats(compute(RandomReal(−10), n, 1, 1000000))
−9.99999550637 −5.00195625251 −1.34715810418⋅10^−5
stats(compute(RandomReal(−10, 10), n, 1, 1000000))
−9.99997942243 −0.0145192105751 9.99999234919