PcgRandom | NET port of the PCG Random Number Generator library | Generator Utils library
kandi X-RAY | PcgRandom Summary
kandi X-RAY | PcgRandom Summary
PcgRandom is a .NET implementation of the PCG family of random number generators.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PcgRandom
PcgRandom Key Features
PcgRandom Examples and Code Snippets
Community Discussions
Trending Discussions on PcgRandom
QUESTION
ANSWER
Answered 2020-Feb-03 at 20:15The notes in the manual page are indicating a difference from the other PCG random number methods that have been studied (by the author of the PCG algorithm at the very least).
The issue with floating-point numbers is indeed related to floating-point number density. See http://www.pcg-random.org/using-pcg-c-basic.html#generating-doubles from the PCG author. It is a potential problem even when generating random numbers in [0.0, 1.0]. This paragraph from the documentation describes the issue:
When generating a real, imaginary, or complex number, this implementation uses the strategy of generating a 64-bit unsigned integer and then multiplying it by 2.0**-64 in order to convert it to a floating point number. While this does construct a uniform distribution on rounded floating point values, it leaves out many possible real values (for example, 2**-128). We believe that this strategy has reasonable statistical properties. One side effect of this strategy is that the real number 1.0 can be generated because of rounding. The real number 0.0 can be generated because PCG can produce the value 0 as a random integer.
Note that a 64-bit real can store numbers as small as 2.0**-1024
but it is quite impossible to get such a number by dividing a positive integer by 2**64
. (Here and in the above I am using **
as the exponentiation operator, as that is what it does in Chapel syntax). I recommend reading up on IEEE floating point formats (e.g. https://en.wikipedia.org/wiki/IEEE_754 or https://en.wikipedia.org/wiki/Double-precision_floating-point_format ) for background information in this area. You might care about this if you were using an RNG to generate test inputs to an algorithm operating on real(64)
values. In that event you might wish for even the very small values to be generated. Note though that constructing an RNG that can generate all real(64)
values in a non-uniform manner is not so hard (e.g. just by copying the bits from a uint
into a real
).
Regarding the other part of your question:
I did some basic statistical testing with the generation of random integers in a particular range with TestU01 and I'd be confident in its use with Monte Carlo calculations. However I am not an expert in this area and as a result I put that warning in the documentation. The below information from the documentation describes the testing that I did:
We have tested this implementation with TestU01 (available at http://simul.iro.umontreal.ca/testu01/tu01.html ). We measured our implementation with TestU01 1.2.3 and the Crush suite, which consists of 144 statistical tests. The results were:
- no failures for generating uniform reals
- 1 failure for generating 32-bit values (which is also true for the reference version of PCG with the same configuration)
- 0 failures for generating 64-bit values (which we provided to TestU01 as 2 different 32-bit values since it only accepts 32 bits at a time)
- 0 failures for generating bounded integers (which we provided to TestU01 by requesting values in
[0..,2**31+2**30+1)
until we had two values < 2**31, removing the top 0 bit, and then combining the top 16 bits into the value provided to TestU01).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PcgRandom
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page