rand - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


MapleTA[Builtin]

  

rand

  

generate random real numbers

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

rand(m, n)

rand(m, n, k)

Parameters

m, n

-

numeric

k

-

posint

Description

• 

The rand command returns a random real number between m and n (inclusive). For example, to generate random numbers between 0.5 and 9.5, use the formula: rand(0.5, 9.5)

• 

Using the three-argument form, rand returns a random real number between m and n expressed to k significant digits. For example, to generate numbers between 2.73 and 7.91 to two significant figures, use: rand(2.73, 7.91, 2).

• 

Note: In this definition, the dummy variable k represents the number of significant figures, not the step size (as it indicates in defining range and rint). To generate random numbers that vary an order of magnitude and have the same number of decimal digits, use the decimal command in conjunction with the rand command. For example, to generate a random number between 2 and 20 with one decimal place, use: decimal(1, rand(2, 20, 3) )

Examples

MapleTA:-Builtin:-rand0.5,9.5

6.871587673

(1)

MapleTA:-Builtin:-rand2.73,7.91,2

7.1

(2)

Compatibility

• 

The MapleTA[Builtin][rand] command was introduced in Maple 18.

• 

For more information on Maple 18 changes, see Updates in Maple 18.

See Also

MapleTA

MapleTA,Builtin,decimal

MapleTA,Builtin,int

MapleTA,Builtin,range

MapleTA,Builtin,sig