 RandomTools Flavor: nonnegative - Maple Programming Help

Home : Support : Online Help : Programming : Random Objects : RandomTools package : Flavors : RandomTools/flavor/nonnegative

RandomTools Flavor: nonnegative

describe a flavor of a random non-negative rational number

 Calling Sequence nonnegative nonnegative(opts)

Parameters

 opts - equation(s) of the form option = value where option is one of range, character, or denominator; specify options for the random non-negative rational number

Description

 • The flavor nonnegative describes a random non-negative rational number in a particular range.
 To describe a flavor of a random non-negative rational number, use either nonnegative or nonnegative(opts) (where opts is described following) as the argument to RandomTools[Generate] or as part of a structured flavor.
 • By default, the flavor nonnegative describes a random rational number in the range $0..1$ with a denominator of $999999999989$, or the integer $0$ or $1$.
 • You can modify the properties of a random rational number by using the rational(opts) form of this flavor. The opts argument can contain one or more of the following equations.
 range = b
 This option describes the right endpoint of the range from which the random rational number is chosen. The right endpoint must be of type rational and nonnegative and it describes a random rational number in the interval $0..b$, where $0$ is included and the inclusiveness of b is determined by the character option.
 character = open or closed
 This option specifies whether to include the right endpoint of the range from which the random rational number is chosen. The default value for this option is open.
 denominator = posint
 This option specifies the positive integer to use as the denominator for the random rational number that is generated. Note: The return value may be an integer, or a fraction with a denominator that is a factor of the specified integer.
 The default denominator is $999999999989$.
 In the case of the closed interval $0..1$, the denominator is prime. Therefore, a result of $\frac{1}{3}$ cannot occur. Instead, you can specify a denominator that is highly composite. For example, $720720$.

Examples

 > $\mathrm{with}\left(\mathrm{RandomTools}\right):$
 > $\mathrm{Generate}\left(\mathrm{nonnegative}\right)$
 $\frac{{395718860534}}{{999999999989}}$ (1)
 > $\mathrm{Generate}\left(\mathrm{nonnegative}\left(\mathrm{range}=5\right)\right)$
 $\frac{{3224811806585}}{{999999999989}}$ (2)
 > $\mathrm{Generate}\left(\mathrm{nonnegative}\left(\mathrm{range}=\frac{1}{2},\mathrm{denominator}=720720\right)\right)$
 $\frac{{4019}}{{20020}}$ (3)
 > $\mathrm{Generate}\left(\mathrm{nonnegative}\left(\mathrm{denominator}=10\right)\right)$
 $\frac{{1}}{{2}}$ (4)
 > $\mathrm{sort}\left(\left[\mathrm{seq}\left(\mathrm{Generate}\left(\mathrm{nonnegative}\left(\mathrm{denominator}=6,\mathrm{character}=\mathrm{closed}\right)\right),i=1..10\right)\right],'\mathrm{numeric}'\right)$
 $\left[{0}{,}\frac{{1}}{{6}}{,}\frac{{1}}{{6}}{,}\frac{{1}}{{3}}{,}\frac{{1}}{{3}}{,}\frac{{1}}{{2}}{,}\frac{{1}}{{2}}{,}\frac{{2}}{{3}}{,}\frac{{2}}{{3}}{,}\frac{{5}}{{6}}\right]$ (5)
 > $\mathrm{Generate}\left(\mathrm{list}\left(\mathrm{nonnegative}\left(\mathrm{range}=\frac{13}{2}\right),5\right)\right)$
 $\left[\frac{{3273442022561}}{{999999999989}}{,}\frac{{5574741247155}}{{999999999989}}{,}\frac{{1339845829802}}{{999999999989}}{,}\frac{{2584712523356}}{{999999999989}}{,}\frac{{6104959978545}}{{999999999989}}\right]$ (6)
 > $\mathrm{seq}\left(\mathrm{Generate}\left(\mathrm{nonnegative}\left(\mathrm{range}=7,\mathrm{denominator}=720720\right)\right),i=1..10\right)$
 $\frac{{2440381}}{{360360}}{,}\frac{{669697}}{{102960}}{,}\frac{{22041}}{{7280}}{,}\frac{{754207}}{{120120}}{,}\frac{{340793}}{{102960}}{,}\frac{{353201}}{{60060}}{,}\frac{{1715821}}{{720720}}{,}\frac{{1432777}}{{240240}}{,}\frac{{129287}}{{72072}}{,}\frac{{28147}}{{11440}}$ (7)
 > $\mathrm{Matrix}\left(3,3,\mathrm{Generate}\left(\mathrm{nonnegative}\left(\mathrm{denominator}=24\right)\mathrm{identical}\left(x\right)+\mathrm{nonnegative}\left(\mathrm{denominator}=16\right),\mathrm{makeproc}=\mathrm{true}\right)\right)$
 $\left[\begin{array}{ccc}\frac{{7}{}{x}}{{12}}{+}\frac{{7}}{{8}}& \frac{{3}{}{x}}{{4}}{+}\frac{{1}}{{4}}& \frac{{11}{}{x}}{{24}}{+}\frac{{1}}{{8}}\\ \frac{{7}{}{x}}{{24}}{+}\frac{{9}}{{16}}& \frac{{x}}{{12}}& \frac{{2}{}{x}}{{3}}{+}\frac{{1}}{{8}}\\ \frac{{x}}{{6}}{+}\frac{{1}}{{4}}& \frac{{3}{}{x}}{{8}}{+}\frac{{9}}{{16}}& \frac{{3}{}{x}}{{8}}{+}\frac{{5}}{{8}}\end{array}\right]$ (8)