 float - Maple Help

RandomTools Flavor: float

describe a flavor of a random floating-point number Calling Sequence float float(opts) Parameters

 opts - equation(s) of the form option = value where option is one of range, digits, or method; specify options for the random floating-point number Description

 • The flavor float describes a random floating-point number in a particular range.
 To describe a flavor of a random floating-point number, use either float or float(opts) (where opts is described following) as the argument to RandomTools[Generate] or as part of a structured flavor.
 • By default, the flavor float describes a random floating-point number logarithmically distributed in the range epsilon..1.0 - epsilon, inclusive, where epsilon = 10e-Digits.
 • You can modify the properties of the random floating-point number by using the float(opts) form of this flavor. The opts argument can contain one or more of the following equations.
 range = a..b
 This option specifies the range from which the random float is chosen. The range endpoints a and b are numeric and when using method=logarithmic, either a >= 0.0 or b <= 0.0.  All numerics are evaluated by using the setting of the digits option.
 If $a=0.$, then $a$ is set to the smallest value of the form $\mathrm{1eN}$ such that $b+\mathrm{1eN}>b$. If $b=0.$, then $b$ is set to the smallest value of the form $-\mathrm{1eN}$ such that $a-\mathrm{1eN}.
 If $b, an exception is raised.
 digits = posint
 This option specifies a positive integer to use as the Digits setting. The default setting is the current setting of the Digits environment variable.
 method = uniform or logarithmic
 This option specifies whether the floating-point number should be chosen logarithmically or uniformly from the interval.
 The logarithmic method is identical to listing all of the unique floating-point numbers that are found between the endpoints, and then choosing one of these randomly.
 The uniform method is similar to sampling from a uniform distribution that is bounded by the endpoints, and then converting this result into a floating-point number.
 The default value for this option is uniform. Examples

 > $\mathrm{with}\left(\mathrm{RandomTools}\right):$
 > $\mathrm{Generate}\left(\mathrm{float}\right)$
 ${0.2342493224}$ (1)
 > $\mathrm{Generate}\left(\mathrm{float}\left(\mathrm{range}=2.532..7.723,\mathrm{digits}=4\right)\right)$
 ${2.537}$ (2)
 > $\left[\mathrm{seq}\left(\mathrm{Generate}\left(\mathrm{float}\right),i=1..10\right)\right]$
 $\left[{0.4077358422}{,}{0.5684678711}{,}{0.3475034102}{,}{0.2026591600}{,}{0.5479226237}{,}{0.008823971507}{,}{0.2074604148}{,}{0.9290936515}{,}{0.6664697983}{,}{0.3909313924}\right]$ (3)
 > $\mathrm{sort}\left(\left[\mathrm{seq}\left(\mathrm{Generate}\left(\mathrm{float}\left(\mathrm{range}=0.0321..162.0,\mathrm{digits}=3\right)\right),i=1..10\right)\right]\right)$
 $\left[{10.4}{,}{15.9}{,}{58.9}{,}{64.2}{,}{66.7}{,}{87.8}{,}{89.0}{,}{91.4}{,}{124.}{,}{129.}\right]$ (4)
 > $\mathrm{sort}\left(\left[\mathrm{seq}\left(\mathrm{Generate}\left(\mathrm{float}\left(\mathrm{range}=0.0321..162.0,\mathrm{digits}=3,\mathrm{method}=\mathrm{logarithmic}\right)\right),i=1..10\right)\right]\right)$
 $\left[{0.0475}{,}{0.0522}{,}{0.0778}{,}{0.0963}{,}{0.237}{,}{0.289}{,}{0.801}{,}{0.918}{,}{9.15}{,}{87.1}\right]$ (5)
 > $\mathrm{Matrix}\left(3,3,\mathrm{Generate}\left(\mathrm{float}\left(\mathrm{range}=2..7\right)\mathrm{identical}\left(x\right)+\mathrm{float}\left(\mathrm{range}=2..7\right),\mathrm{makeproc}=\mathrm{true}\right)\right)$
 $\left[\begin{array}{ccc}{6.832623175}{}{x}{+}{4.850164008}& {2.540721923}{}{x}{+}{2.219972873}& {2.156513983}{}{x}{+}{3.755486969}\\ {4.094092595}{}{x}{+}{5.955127111}& {5.468319344}{}{x}{+}{2.012105075}& {5.052449900}{}{x}{+}{5.323948758}\\ {5.765644424}{}{x}{+}{5.471087299}& {2.076338300}{}{x}{+}{5.527224675}& {3.817480335}{}{x}{+}{2.678852156}\end{array}\right]$ (6)
 > $\mathrm{plots}\left[\mathrm{listplot}\right]\left(\mathrm{sort}\left(\left[\mathrm{seq}\left(\mathrm{Generate}\left(\mathrm{float}\left(\mathrm{range}=0.0321..162.0,\mathrm{digits}=3\right)\right),i=1..20\right)\right]\right)\right)$
 > $\mathrm{plots}\left[\mathrm{listplot}\right]\left(\mathrm{sort}\left(\left[\mathrm{seq}\left(\mathrm{Generate}\left(\mathrm{float}\left(\mathrm{range}=0.0321..162.0,\mathrm{digits}=3,\mathrm{method}=\mathrm{uniform}\right)\right),i=1..20\right)\right]\right)\right)$