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/Box–Muller_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(_at_)mitre(_dot_)org
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> 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
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--