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.
|
|
This option specifies the range from which the random float is chosen. The range endpoints a and b are numeric and either a >= 0.0 or b <= 0.0. All numerics are evaluated by using the setting of the digits option.
|
|
If , an exception is raised.
|
|
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 logarithmic.
|
|
|
Examples
|
|
>
|
|
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
| (4) |
>
|
|
| (5) |
>
|
|
| (6) |
>
|
|
>
|
|
|
|
Download Help Document
Was this information helpful?