RandomTools Flavor: float - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

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 either a >= 0.0 or b <= 0.0.  All numerics are evaluated by using the setting of the digits option.

  

If a&equals;0., then a is set to the smallest value of the form 1eN such that b+1eN>b. If b&equals;0., then b is set to the smallest value of the form 1eN such that a1eN<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 logarithmic.

Examples

withRandomTools&colon;

Generatefloat

0.001715876735

(1)

Generatefloatrange&equals;2.532..7.723&comma;digits&equals;4

2.537

(2)

seqGeneratefloat&comma;i&equals;1..10

8.01092959410-10&comma;0.00003663573095&comma;5.67097722110-8&comma;0.01831937262&comma;4.32403388210-8&comma;0.06183108282&comma;0.08394083871&comma;0.0004646025782&comma;7.46727562710-7&comma;0.0006955563440

(3)

sortseqGeneratefloatrange&equals;0.0321..162.0&comma;digits&equals;3&comma;i&equals;1..10

0.0771&comma;0.317&comma;0.483&comma;1.49&comma;2.01&comma;9.62&comma;12.4&comma;25.3&comma;77.1&comma;88.1

(4)

sortseqGeneratefloatrange&equals;0.0321..162.0&comma;digits&equals;3&comma;method&equals;uniform&comma;i&equals;1..10

15.9&comma;29.0&comma;40.6&comma;58.9&comma;62.0&comma;64.2&comma;66.7&comma;87.8&comma;91.4&comma;124.

(5)

Matrix3&comma;3&comma;Generatefloatrange&equals;2..7identicalx&plus;floatrange&equals;2..7&comma;makeproc&equals;true

2.198304612x&plus;2.4171778014.984266209x&plus;6.0811726092.147944788x&plus;3.8843926785.287869586x&plus;3.9137781545.046698742x&plus;3.1855186812.698412071x&plus;2.5110911416.122068897x&plus;3.4619455564.513705832x&plus;5.2266674544.350272820x&plus;2.595387438

(6)

plots&lsqb;listplot&rsqb;sortseqGeneratefloatrange&equals;0.0321..162.0&comma;digits&equals;3&comma;i&equals;1..20

plots&lsqb;listplot&rsqb;sortseqGeneratefloatrange&equals;0.0321..162.0&comma;digits&equals;3&comma;method&equals;uniform&comma;i&equals;1..20

See Also

ceil

Digits

flavor/structured

Float

floor

rand

RandomTools

RandomTools[Generate]

round

trunc

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam