RandomTools - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Random Objects : RandomTools package : Commands : RandomTools/Generate

RandomTools

 Generate
 generate a particular random object

 Calling Sequence Generate(expr)

Parameters

 expr - expression; defines the form of the random object

Description

 • The Generate(expr) function generates a particular random object that is determined by expr. The expr parameter is used to:
 * indicate a particular Maple type,
 * indicate a flavor template, where specific keywords describe the form of the returned random object, or
 * choose a random entry from a Maple data structure.
 The following list describes the Maple types, flavor templates, and data structures that are recognized by Generate. For more information about how to generate a random number that corresponds to one of these items, see the corresponding help page (flavor/).

 • The Generate function calls the Maple rand procedure.
 • The Generate function maps onto all objects that are not of type atomic.
 • This function is part of the RandomTools package, and so it can be used in the form Generate(..) only after executing the command with(RandomTools). However, it can always be accessed through the long form of the command by using the form RandomTools[Generate](..).

Examples

 > $\mathrm{with}\left(\mathrm{RandomTools}\right):$
 > $\mathrm{Generate}\left(\mathrm{integer}\right)$
 ${-}{104281139460}$ (1)
 > $\mathrm{Generate}\left(\mathrm{list}\left(\mathrm{float},3\right)\right)$
 $\left[{0.001715876735}{,}{0.0002700862948}{,}{5.424170466}{}{{10}}^{{-8}}\right]$ (2)
 > $\mathrm{Generate}\left(\left[\mathrm{negint},\mathrm{integer},\mathrm{float}\right]\right)$
 $\left[{-}{84764803536}{,}{342622684448}{,}{8.344539878}{}{{10}}^{{-7}}\right]$ (3)
 > $\mathrm{Matrix}\left(3,3,\mathrm{Generate}\left(\mathrm{rational}\left(\mathrm{denominator}=10\right),\mathrm{makeproc}=\mathrm{true}\right)\right)$
 $\left[\begin{array}{ccc}{-}\frac{{4}}{{5}}& \frac{{4}}{{5}}& \frac{{1}}{{10}}\\ \frac{{9}}{{10}}& \frac{{2}}{{5}}& \frac{{4}}{{5}}\\ \frac{{1}}{{2}}& {-}\frac{{1}}{{5}}& {0}\end{array}\right]$ (4)
 > $\mathrm{Matrix}\left(3,3,\mathrm{Generate}\left(\mathrm{rational}\left(\mathrm{denominator}=10\right),\mathrm{makeproc}=\mathrm{true}\right)\right)$
 $\left[\begin{array}{ccc}\frac{{2}}{{5}}& \frac{{1}}{{5}}& {-}\frac{{1}}{{10}}\\ \frac{{3}}{{10}}& \frac{{3}}{{5}}& {-}\frac{{9}}{{10}}\\ {-}\frac{{2}}{{5}}& \frac{{3}}{{10}}& \frac{{2}}{{5}}\end{array}\right]$ (5)
 > $\mathrm{Vector}\left(4,\mathrm{Generate}\left(\mathrm{complex}\left(\mathrm{integer}\left(\mathrm{range}=1..100\right)\right),\mathrm{makeproc}=\mathrm{true}\right)\right)$
 $\left[\begin{array}{c}{39}{+}{92}{}{I}\\ {71}{+}{67}{}{I}\\ {78}{+}{51}{}{I}\\ {53}{+}{12}{}{I}\end{array}\right]$ (6)

 See Also