RandomTools Flavor: float
describe a flavor of a random floating-point number
Calling Sequence
Parameters
Description
Examples
float
float(opts)
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
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 1eN such that b+1eN>b. If b=0., then b is set to the smallest value of the form −1eN such that a−1eN<a.
If b<a, 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.
with⁡RandomTools:
Generate⁡float
0.2342493224
Generate⁡float⁡range=2.532..7.723,digits=4
2.537
seq⁡Generate⁡float,i=1..10
0.4077358422,0.5684678711,0.3475034102,0.2026591600,0.5479226237,0.008823971507,0.2074604148,0.9290936515,0.6664697983,0.3909313924
sort⁡seq⁡Generate⁡float⁡range=0.0321..162.0,digits=3,i=1..10
10.4,15.9,58.9,64.2,66.7,87.8,89.0,91.4,124.,129.
sort⁡seq⁡Generate⁡float⁡range=0.0321..162.0,digits=3,method=logarithmic,i=1..10
0.0475,0.0522,0.0778,0.0963,0.237,0.289,0.801,0.918,9.15,87.1
Matrix⁡3,3,Generate⁡float⁡range=2..7⁢identical⁡x+float⁡range=2..7,makeproc=true
6.832623175⁢x+4.8501640082.540721923⁢x+2.2199728732.156513983⁢x+3.7554869694.094092595⁢x+5.9551271115.468319344⁢x+2.0121050755.052449900⁢x+5.3239487585.765644424⁢x+5.4710872992.076338300⁢x+5.5272246753.817480335⁢x+2.678852156
plotslistplot⁡sort⁡seq⁡Generate⁡float⁡range=0.0321..162.0,digits=3,i=1..20
plotslistplot⁡sort⁡seq⁡Generate⁡float⁡range=0.0321..162.0,digits=3,method=uniform,i=1..20
See Also
ceil
Digits
flavor/structured
Float
floor
rand
RandomTools
RandomTools[Generate]
round
trunc
Download Help Document