Difference between revisions of "Random Module"

From BaseX Documentation
Jump to navigation Jump to search
m (Text replace - "{|" to "{| width='100%'")
m (Text replace - "| width='90' | '''Signatures'''" to "| width='120' | '''Signatures'''")
Line 11: Line 11:
 
{| width='100%'
 
{| width='100%'
 
|-
 
|-
| width='90' | '''Signatures'''
+
| width='120' | '''Signatures'''
 
|{{Func|random:double||xs:double}}<br />
 
|{{Func|random:double||xs:double}}<br />
 
|-
 
|-
Line 24: Line 24:
 
{| width='100%'
 
{| width='100%'
 
|-
 
|-
| width='90' | '''Signatures'''
+
| width='120' | '''Signatures'''
 
|{{Func|random:integer||xs:integer}}<br />{{Func|random:integer|$max as xs:integer|xs:integer}}<br />
 
|{{Func|random:integer||xs:integer}}<br />{{Func|random:integer|$max as xs:integer|xs:integer}}<br />
 
|-
 
|-
Line 37: Line 37:
 
{| width='100%'
 
{| width='100%'
 
|-
 
|-
| width='90' | '''Signatures'''
+
| width='120' | '''Signatures'''
 
|{{Func|random:seeded-double|$seed as xs:integer, $num as xs:integer|xs:double*}}<br />
 
|{{Func|random:seeded-double|$seed as xs:integer, $num as xs:integer|xs:double*}}<br />
 
|-
 
|-
Line 50: Line 50:
 
{| width='100%'
 
{| width='100%'
 
|-
 
|-
| width='90' | '''Signatures'''
+
| width='120' | '''Signatures'''
 
|{{Func|random:seeded-integer|$seed as xs:integer, $num as xs:integer|xs:integer*}}<br />{{Func|random:seeded-integer|$seed as xs:integer, $num as xs:integer, $max as xs:integer|xs:integer*}}
 
|{{Func|random:seeded-integer|$seed as xs:integer, $num as xs:integer|xs:integer*}}<br />{{Func|random:seeded-integer|$seed as xs:integer, $num as xs:integer, $max as xs:integer|xs:integer*}}
 
|-
 
|-
Line 63: Line 63:
 
{| width='100%'
 
{| width='100%'
 
|-
 
|-
| width='90' | '''Signatures'''
+
| width='120' | '''Signatures'''
 
|{{Func|random:gaussian|$num as xs:integer|xs:double*}}<br />
 
|{{Func|random:gaussian|$num as xs:integer|xs:double*}}<br />
 
|-
 
|-
Line 76: Line 76:
 
{| width='100%'
 
{| width='100%'
 
|-
 
|-
| width='90' | '''Signatures'''
+
| width='120' | '''Signatures'''
 
|{{Func|random:uuid||xs:string}}
 
|{{Func|random:uuid||xs:string}}
 
|-
 
|-

Revision as of 10:37, 14 June 2013

This XQuery Module contains non-deterministic functions for returning random values.

Conventions

All functions in this module are assigned to the http://basex.org/modules/random namespace, which is statically bound to the random prefix.
All errors are assigned to the http://basex.org/errors namespace, which is statically bound to the bxerr prefix.

Functions

random:double

Signatures random:double() as xs:double
Summary Returns a double value between 0.0 (inclusive) and 1.0 (exclusive).

random:integer

Signatures random:integer() as xs:integer
random:integer($max as xs:integer) as xs:integer
Summary Returns an integer value, either in the whole integer range or between 0 (inclusive) and the given maximum (exclusive)

random:seeded-double

Signatures random:seeded-double($seed as xs:integer, $num as xs:integer) as xs:double*
Summary Returns a sequence with $num double values between 0.0 (inclusive) and 1.0 (exclusive). The random values are created using the initial seed given in $seed.

random:seeded-integer

Signatures random:seeded-integer($seed as xs:integer, $num as xs:integer) as xs:integer*
random:seeded-integer($seed as xs:integer, $num as xs:integer, $max as xs:integer) as xs:integer*
Summary Returns a sequence with $num integer values, either in the whole integer range or between 0 (inclusive) and the given maximum (exclusive). The random values are created using the initial seed given in $seed.

random:gaussian

Signatures random:gaussian($num as xs:integer) as xs:double*
Summary Returns a sequence with $num double values. The random values are Gaussian (i.e. normally) distributed with the mean 0.0. and the derivation 1.0.

random:uuid

Signatures random:uuid() as xs:string
Summary Creates a random universally unique identifier (UUID), represented as 128-bit value.
Examples
  • random:uuid() eq random:uuid() will (most probably) return the boolean value false.

Changelog

The module was introduced with Version 7.5. It includes some functionality which was previously located in the Math Module.