float - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


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 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 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 uniform.

Examples

withRandomTools&colon;

Generatefloat

0.2342493224

(1)

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

2.537

(2)

seqGeneratefloat&comma;i=1..10

0.4077358422&comma;0.5684678711&comma;0.3475034102&comma;0.2026591600&comma;0.5479226237&comma;0.008823971507&comma;0.2074604148&comma;0.9290936515&comma;0.6664697983&comma;0.3909313924

(3)

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

10.4&comma;15.9&comma;58.9&comma;64.2&comma;66.7&comma;87.8&comma;89.0&comma;91.4&comma;124.&comma;129.

(4)

sortseqGeneratefloatrange=0.0321..162.0&comma;digits=3&comma;method=logarithmic&comma;i=1..10

0.0475&comma;0.0522&comma;0.0778&comma;0.0963&comma;0.237&comma;0.289&comma;0.801&comma;0.918&comma;9.15&comma;87.1

(5)

Matrix3&comma;3&comma;Generatefloatrange=2..7identicalx+floatrange=2..7&comma;makeproc=true

6.832623175x+4.8501640082.540721923x+2.2199728732.156513983x+3.7554869694.094092595x+5.9551271115.468319344x+2.0121050755.052449900x+5.3239487585.765644424x+5.4710872992.076338300x+5.5272246753.817480335x+2.678852156

(6)

plotslistplotsortseqGeneratefloatrange=0.0321..162.0&comma;digits=3&comma;i=1..20

plotslistplotsortseqGeneratefloatrange=0.0321..162.0&comma;digits=3&comma;method=uniform&comma;i=1..20

See Also

ceil

Digits

flavor/structured

Float

floor

rand

RandomTools

RandomTools[Generate]

round

trunc