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

Online Help

All Products    Maple    MapleSim


RandomTools Flavor: set

describe a set of random objects

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

set(flav, n)

set(flav, n, opt)

Parameters

flav

-

random flavor

n

-

non-negative integer

opt

-

(optional) one or more keyword options of the form keyword = value, where the keyword is either exact or limit 

Description

• 

The flavor set describes a set containing n entries where the entries of this set are described by the given random flavor flav.

• 

By default, the final set can contain fewer than n entries if the same object is generated more than once. If the exact = true option is given, either as the keyword or as the equation exact = true, then a set of exactly n values is returned. For this to succeed, the number of possible values generated by the given flavor has to be at least n. This can be detected reliably for some flavors such as integer or choose, but not for all flavors. The option exact = true can also be specified as just exact; the default can be specified explicitly as exact = false.

• 

If Maple cannot detect whether the flavor supports at least n values and the exact option is set to true, then it will try to generate sufficiently many values. However, this may fail. In this situation, if Maple runs a certain limit number of iterations, it will error out. By default, this limit is 100 iterations; it can be set to any positive number using the limit option, or to infinity to disable the limit. If the exact option is not set to true, the limit option is ignored.

  

This flavor can be used as an argument to RandomTools[Generate] or as part of a structured flavor.

Examples

withRandomTools:

The following sets have fewer than 10 entries, because some entries were generated twice.

Generatesetposintrange=10,10

1,2,4,5,6,7,8,10

(1)

Generatesetrationaldenominator=6,10

23,12,13,12,13,23,56

(2)

This is corrected with the exact option.

Generatesetrationaldenominator=6,10,exact

0,56,23,12,16,12,13,16,23,56

(3)

The following will fail, because there are only 11 values that can be generated.

Generatesetrationaldenominator=6,100,exact

Error, (in RandomTools:-Generate) requested exactly 100 different random entries, but unsuccessful after 100 iterations (11 were found)

The following should eventually succeed, because there are 15625 possible lists of the given flavor. However, Maple does not have specialized code to detect this case. Trying to generate almost all possible entries by random chance is likely to take a large number of iterations, so it will most probably fail in this case.

Generatesetlistintegerrange=1..5,6,15600,exact

Error, (in RandomTools:-Generate) requested exactly 15600 different random entries, but unsuccessful after 100 iterations (15533 were found)

If we set the limiting number of iterations sufficiently high, we do get the correct result.

resultGeneratesetlistintegerrange=1..5,6,15600,exact,limit=:

numelemsresult

15600

(4)

Compatibility

• 

The RandomTools Flavor: set command was updated in Maple 2019.

• 

The exact and limit options were introduced in Maple 2019.

• 

For more information on Maple 2019 changes, see Updates in Maple 2019.

See Also

flavor/structured

rand

RandomTools

RandomTools[Generate]

set