Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 43 |
Nodes: | 6 (0 / 6) |
Uptime: | 94:26:46 |
Calls: | 290 |
Calls today: | 1 |
Files: | 904 |
Messages: | 76,378 |
This has probably been posted in c.l.f. before (by MHX or others) but
you can find my Forth implementation of G. Marsaglia's KISS 64-bit
PRNG at the link below.
I would like to recommend Marsaglia's newer and better xorshift family
of PRNGs, and preferably the further development by Sebastiano Vigna
called xoroshiro. The output (with suitable parameters) is very good*,
yet the implementation is very simple.
*But not cryptography grade.
On Mon, 9 Sep 2024 6:55:49 +0000, Lars Brinkhoff wrote:
[..]
I would like to recommend Marsaglia's newer and better xorshift family
of PRNGs, and preferably the further development by Sebastiano Vigna
called xoroshiro. The output (with suitable parameters) is very good*,
yet the implementation is very simple.
*But not cryptography grade.
Being "cryptography grade" is the point when you want to introduce
something new for a PRNG :--)
1320>> : RANDOM seed $107465 * $234567 + ( -- u )
1321: 9 ROL DUP TO seed ;
1320>> : RANDOM seed $107465 * $234567 + ( -- u )
1321: 9 ROL DUP TO seed ;
So this is a linear congruential generator enhanded with the 9 ROL.
LCGs have known weaknesses that are relevant even for
non-cryptographic applications. Maybe the ROL fixes those; have you
run it through ransomness testers?
mhx@iae.nl (mhx) writes:
On Mon, 9 Sep 2024 6:55:49 +0000, Lars Brinkhoff wrote:
[..]
I would like to recommend Marsaglia's newer and better xorshift family
of PRNGs, and preferably the further development by Sebastiano Vigna
called xoroshiro. The output (with suitable parameters) is very good*,
yet the implementation is very simple.
*But not cryptography grade.
Being "cryptography grade" is the point when you want to introduce >>something new for a PRNG :--)
Having better randomness at the same speed or better speed with
similar randomness is also relevant outside cryptographic
applications.
1320>> : RANDOM seed $107465 * $234567 + ( -- u )
1321: 9 ROL DUP TO seed ;
So this is a linear congruential generator enhanded with the 9 ROL.
LCGs have known weaknesses that are relevant even for
non-cryptographic applications. Maybe the ROL fixes those; have you
run it through ransomness testers?
- anton
I know Marcel uses the random generator for games, which is
okay.
Krishna Myneni wrote:
This has probably been posted in c.l.f. before (by MHX or others) but
you can find my Forth implementation of G. Marsaglia's KISS 64-bit
PRNG at the link below.
I would like to recommend Marsaglia's newer and better xorshift family
of PRNGs, and preferably the further development by Sebastiano Vigna
called xoroshiro. The output (with suitable parameters) is very good*,
yet the implementation is very simple.
*But not cryptography grade.
albert@spenarnc.xs4all.nl writes:
I know Marcel uses the random generator for games, which is
okay.
As a player you don't want a bad PRNG in a game.
- anton
mhx@iae.nl (mhx) writes:...
On Mon, 9 Sep 2024 6:55:49 +0000, Lars Brinkhoff wrote:
[..]
I would like to recommend Marsaglia's newer and better xorshift family
of PRNGs, and preferably the further development by Sebastiano Vigna
called xoroshiro. The output (with suitable parameters) is very good*,
yet the implementation is very simple.
Having better randomness at the same speed or better speed with
similar randomness is also relevant outside cryptographic
applications.
I ran a simple Monte-Carlo integration of the area in a unit circle
using the 64-bit LCG PRNG (from random.4th in kForth dist) and
Marsaglia's 64-bit KISS PRNG. Hard to say which is better for this problem.
--
Krishna
=== Comparison of 64-bit LCG and KISS PRNGs ===
PRNG: RANDOM (random.4th)
Ntrials Area log(error)
-------------------------------
10^2 3.28 -0.86
10^3 3.18 -1.42
10^4 3.1724 -1.51
10^5 3.14048 -2.95
10^6 3.14350 -2.72
10^7 3.14225 -3.18
10^8 3.14152 -4.14
PRNG: RAN-KISS (kiss.4th)
Ntrials Area log(error)
-------------------------------
10^2 3.24 -1.01
10^3 3.10 -1.38
10^4 3.1252 -1.79
10^5 3.14084 -3.12
10^6 3.14073 -3.06
10^7 3.14184 -3.61
10^8 3.14167 -4.11
On 9/12/24 21:10, Krishna Myneni wrote:[..]
A bit more involved test of the same 64-bit PRNGs starts to show the possibility of defects in Marsaglia's 64-bit kiss prng (RAN-KISS)[..]
compared to a simple 64-bit LCG prng (RANDOM).
On Thu, 19 Sep 2024 0:28:33 +0000, Krishna Myneni wrote:
On 9/12/24 21:10, Krishna Myneni wrote:[..]
A bit more involved test of the same 64-bit PRNGs starts to show the[..]
possibility of defects in Marsaglia's 64-bit kiss prng (RAN-KISS)
compared to a simple 64-bit LCG prng (RANDOM).
I wonder if it is at all possible to really prove something
about the PRNG *with tests of this type*. Intuition wants us to
believe that the longer we run the simulation, the closer
the result must match the expected outcome. Shouldn't we
compute the probability that after a certain size run the
result does NOT match the known result (given an ideal PRNG),
or how unlikely it is that the result has a given error?
Example: say the result of PRNG-a consistently has one of
its bits (say bit 0) stuck at zero. Would the test under
consideration detect this specific problem at all?
Moments of speed
N <v> (m/s) <v^2> (m/s)^2 <v^3> (m/s)^3
10^2 1181.0956 1656472.7 2604709063.
10^3 1293.3130 1952149.7 3300955817.
10^4 1259.3279 1862988.3 3108515117.
10^5 1260.5577 1872157.8 3147664636.
10^6 1259.4425 1868918.9 3139487337.
10^7 1259.6136 1869145.0 3139092438.
--
Krishna
On 9/19/24 03:57, albert@spenarnc.xs4all.nl wrote:
In article <vcgok8$gol7$1@dont-email.me>,
Krishna Myneni <krishna.myneni@ccreweb.org> wrote:
<SNIP>
Moments of speed
N <v> (m/s) <v^2> (m/s)^2 <v^3> (m/s)^3
10^2 1181.0956 1656472.7 2604709063.
10^3 1293.3130 1952149.7 3300955817.
10^4 1259.3279 1862988.3 3108515117.
10^5 1260.5577 1872157.8 3147664636.
10^6 1259.4425 1868918.9 3139487337.
10^7 1259.6136 1869145.0 3139092438.
I think for a Monte Carlo simulation at least three tests
must be done with different seeds.
Good point. For a meaningful comparison of errors between PRNGs at a
specific N, the statistical variation of the <v^n> need to be measured
for different seed values.
I can add some code to measure this sigma at each N, with 32 seeds
uniformly spaced between 0 and UMAX.
I've calculated the statistical variation in the moments for each set of
N, using 16 different seeds (spaced apart over the interval for UMAX).
The standard dev. for the 16 <v^i>, computed for N trials is comparable
to the relative error between the moment and its theoretical value.
Thus, the relative errors are indeed a meaningful comparison between the
two prngs tested here, and I think this implies that for N > 10^5 the
LCG PRNG (RANDOM) gives more accurate answers than the KISS 64 bit PRNG (RAN-KISS), for this problem. The LCG PRNG is faster than the KISS
64-bit PRNG. ...
On 9/9/24 03:55, Anton Ertl wrote:
mhx@iae.nl (mhx) writes:...
On Mon, 9 Sep 2024 6:55:49 +0000, Lars Brinkhoff wrote:
[..]
I would like to recommend Marsaglia's newer and better xorshift family >>>> of PRNGs, and preferably the further development by Sebastiano Vigna
called xoroshiro. The output (with suitable parameters) is very good*, >>>> yet the implementation is very simple.
Having better randomness at the same speed or better speed with
similar randomness is also relevant outside cryptographic
applications.
Supposedly "good" PRNGs give large errors compared to theoretical values
for some physics simulations. These errors have been studied for a 2D
Ising model of ferromagnetism at the phase transition temperature, T =
T_c (transition from ordered spins to disordered spins).
Ref. [1] shows that a simple 32-bit congruential generator (CONG) gave
more accurate answers for the average energy <E> and specific heat <C>
of the model lattice in Monte-Carlo simulations than the supposedly
superior R250 XOR based shift register generator or a subtract with
carry generator (SWC) -- incidentally, the R250 generator is included in
the FSL. All other things being the same for the simulations, the
following errors (in std deviations) were observed with the different
PRNGs:
PRNG error in <E> error in <C>
CONG -0.31 0.82
R250 42.09 -107.16
SWC -16.95 32.81
Marsaglia's 64-bit KISS PRNG. Hard to say which is better for this problem.
Krishna Myneni <krishna.myneni@ccreweb.org> writes:
Marsaglia's 64-bit KISS PRNG. Hard to say which is better for this
problem.
Try either against a cryptographic PRNG and see if there is enough
difference to satisfy a traditional statistical hypothesis test?
Try either against a cryptographic PRNG
Try either against a cryptographic PRNG
I guess these generators need to be initialized. Wouldn't the outcome
of the integration then depend on the statistical characteristics of
method used to do that initialization?
Try either against a cryptographic PRNGDo they really exist?? The P stands for Pseudo...
In article <vcgok8$gol7$1@dont-email.me>,
Krishna Myneni <krishna.myneni@ccreweb.org> wrote:
<SNIP>
Moments of speed
N <v> (m/s) <v^2> (m/s)^2 <v^3> (m/s)^3
10^2 1181.0956 1656472.7 2604709063.
10^3 1293.3130 1952149.7 3300955817.
10^4 1259.3279 1862988.3 3108515117.
10^5 1260.5577 1872157.8 3147664636.
10^6 1259.4425 1868918.9 3139487337.
10^7 1259.6136 1869145.0 3139092438.
I think for a Monte Carlo simulation at least three tests
must be done with different seeds.