w3c / qtspecs

XSLT and XQuery Specifications - the source used to build the specs, and the errata
Other
30 stars 25 forks source link

fn:random-number-generator() - uniform distribution of results? #12

Closed michaelhkay closed 2 years ago

michaelhkay commented 4 years ago

The spec for fn:random-number-generator() says "The value of the number ... should be such that all eligible xs:double values are equally likely to be chosen." This is unhelpful. This would generate a skewed distribution, since there are more xs:double values in the range [0, 0.1] than there are in the range [0.9, 1.0]. In practice the underlying random number library routine is likely to attempt to deliver a uniform distribution, and most implementations of fn:random-number-generator() are therefore likely to do the same, which is what users are likely to want.

michaelhkay commented 2 years ago

Fixed in the draft 4.0 specification.