float - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

RandomTools Flavor: float

describe a flavor of a random floating-point number

 

Calling Sequence

Parameters

Description

Examples

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 , then  is set to the smallest value of the form  such that . If , then  is set to the smallest value of the form  such that .

  

If , 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

(1)

(2)

(3)

(4)

(5)

(6)

See Also

ceil

Digits

flavor/structured

Float

floor

rand

RandomTools

RandomTools[Generate]

round

trunc

 


Download Help Document