Re: [xsl] Random number generator that returns numbers from a normal probability distribution and with a specified standard deviation?

Subject: Re: [xsl] Random number generator that returns numbers from a normal probability distribution and with a specified standard deviation?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 31 May 2020 18:40:09 -0000
Take a look at the Box Muller transform, which converts a uniformly
distributed set of numbers in the range [0,1] to a set with normal probability
distribution:

https://en.wikipedia.org/wiki/BoxbMuller_transform

XPath 3.1 provides both the random number generator, and the trigonometric
functions needed to do the transformation.

However, there's a question mark over whether the numbers generated by
fn:random-number-generator are "uniformly distributed". The spec says that
"The value of the number ... should be such that all eligible xs:double values
are equally likely to be chosen.". I think there are more xs:double values in
the range (0 to 0.01) than there are in the range (0.99 to 1.00), and if this
is the case then the distribution would be skewed. However, I doubt many
implementations take this provision seriously; they're likely to simply give
you what the underlying random number library gives. The java.util.Random
implementation (see the Javadoc for the nextDouble() method in that class)
strives for an "approximately uniform" distribution.

Michael Kay
Saxonica

> On 31 May 2020, at 18:37, Roger L Costello costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi Folks,
>
> I need a random number generator that returns numbers from a normal
probability distribution, centered around zero, and with standard deviation
that can be specified. Has anyone created such a thing?
>
> I am using XSLT/XPath 2.0
>
> /Roger

Current Thread