[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Random number generator that returns numbers from

Subject: Re: 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
Re:  Random number generator that returns numbers from
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.