random:random-sequence

Delivers a sequence of random numbers between zero and one.

random-sequence($count as xs:integer, $seed as xs:double) ➔ xs:double*

Arguments

 

$count

xs:integer

The number of items required

 

$seed

xs:double

Random number seed

Result

xs:double*

Namespace

http://exslt.org/random

Links to specifications

EXSLT Random Module

Notes on the Saxon implementation

The implementation is deterministic: if called twice with the same seed, it will deliver the same sequence. This property can be useful or a nuisance; if you want a different sequence each time, use something like seconds-from-dateTime() as a seed. The numbers are computed on demand, so there is no harm in setting the first argument to a very high number. It can be useful to use the function in conjunction with xsl:iterate, since this allows early exit.

Saxon also offers the EXSLT math:random() function to compute a single random number, but this is not very useful because it will often be optimized out of a loop, resulting in the same number being chosen each time.