Re: KISS 64-bit pseudo-random number generator

Liste des GroupesRevenir à cl forth 
Sujet : Re: KISS 64-bit pseudo-random number generator
De : krishna.myneni (at) *nospam* ccreweb.org (Krishna Myneni)
Groupes : comp.lang.forth
Date : 10. Sep 2024, 00:36:40
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vbo0q8$2j67c$1@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
On 9/9/24 01:55, Lars Brinkhoff wrote:
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.
There are a variety of non-crypto grade PRNGs in the kForth distributions, which offer different levels of performance as gauged by the dieharder tests of Marsaglia. One can generate large files of the PRNG sequences and then run dieharder on them -- example code given below.
At some point it would be worthwhile to document the dieharder metrics for these existing PRNGs before adding new ones. I think they provide a pretty good range of usable algorithms.
Various PRNGs are provided in the Forth files below (from the kForth distributions):
1. These run on 32 or 64-bit Forths and generate either 32-bit or 64-bit numbers (unsigned).
random.4th -- assorted simple 32/64 bit PRNGs
kiss.4th -- 32/64 bit KISS PRNGs
2. This runs on both 32-bit and 64-bit Forths but, at present, generates only 32 bit numbers (unsigned) or double precision floating point numbers.
mersenne.4th -- Mersenne Twister MT19937 (32-bit PRNG)
3. The following only run on 32-bit Forths at the present time.
ran-next.4th -- Knuth's PRNG (32-bit only; does not run yet on 64-bit)
fsl/isaac.4th -- 32-bit only; does not run yet on 64-bit
4. The following has been tested on 32-bit Forths, but I don't recall if I used/tested the PRNGs under 64-bit yet.
fsl/extras/noise.4th  -- assorted double-prec fp numbers for various random distributions (uniform, gaussian, poissonian).
--
Krishna
=== begin kiss-test.4th ===
\ kiss-test.4th
\
\ Generate pseudo-random numbers with the KISS PRNG
\ to use with the dieharder tests.
\
\ Two output files are written: kiss1.bin and kiss2.bin.
\ These files should be concatenated to make one larger
\ 4GB file, which can then be used with dieharder:
\
\ $ cat kiss1.bin kiss2.bin > kiss.bin
\ $ dieharder -a -g 201 -f kiss.bin
\
\ While 4GB of data won't satisfy the requirement for
\ all of the dieharder tests, it will for most of the
\ diehard subset of tests. This program can be modified
\ easily to generate additional 2GB files of data.
\
\ K. Myneni, 17 June 2016
\ http://ccreweb.org
include strings
include files
include kiss
variable fd
variable s32
: next-u ( -- u ) ran-kiss ;
2variable bytes
: print-bytes ( -- )  bytes 2@ 1 1000000 m*/ d. ."  MB." cr ;
: output-2GB ( -- )
         536870912 0 DO
           next-u s32 !
           s32 4 fd @ write-file drop
           bytes 2@ 4 s>d d+ bytes 2!
           i 20000000 mod 0 = IF print-bytes THEN
         LOOP
;
: next-file ( c-addr u -- )
         W/O create-file
         ABORT" Unable to create output file!"
         fd !
         output-2GB
         fd @ close-file drop
;
: gen ( -- )
    0 s>d bytes 2!
    s" kiss1.bin" next-file
    s" kiss2.bin" next-file
;
gen
=== end kiss-test.4th ===

Date Sujet#  Auteur
9 Sep 24 * KISS 64-bit pseudo-random number generator22Krishna Myneni
9 Sep 24 `* Re: KISS 64-bit pseudo-random number generator21Lars Brinkhoff
9 Sep 24  +* Re: KISS 64-bit pseudo-random number generator19mhx
9 Sep 24  i`* Re: KISS 64-bit pseudo-random number generator18Anton Ertl
9 Sep 24  i +- Re: KISS 64-bit pseudo-random number generator1mhx
9 Sep 24  i +* Re: KISS 64-bit pseudo-random number generator3albert
9 Sep 24  i i`* Re: KISS 64-bit pseudo-random number generator2Anton Ertl
10 Sep 24  i i `- Re: KISS 64-bit pseudo-random number generator1albert
11 Sep 24  i `* Re: KISS 64-bit pseudo-random number generator13Krishna Myneni
13 Sep 24  i  `* Re: KISS 64-bit pseudo-random number generator12Krishna Myneni
13 Sep 24  i   +* Re: KISS 64-bit pseudo-random number generator4Paul Rubin
13 Sep 24  i   i+* Re: KISS 64-bit pseudo-random number generator2mhx
13 Sep 24  i   ii`- Re: KISS 64-bit pseudo-random number generator1Paul Rubin
13 Sep 24  i   i`- Re: KISS 64-bit pseudo-random number generator1minforth
19 Sep 24  i   `* Re: KISS 64-bit pseudo-random number generator7Krishna Myneni
19 Sep 24  i    `* Re: KISS 64-bit pseudo-random number generator6mhx
19 Sep 24  i     +- Re: KISS 64-bit pseudo-random number generator1minforth
19 Sep 24  i     `* Re: KISS 64-bit pseudo-random number generator4Krishna Myneni
19 Sep 24  i      `* Re: KISS 64-bit pseudo-random number generator3Krishna Myneni
26 Sep 24  i       `* Re: KISS 64-bit pseudo-random number generator2Krishna Myneni
26 Sep 24  i        `- Re: KISS 64-bit pseudo-random number generator1Krishna Myneni
10 Sep 24  `- Re: KISS 64-bit pseudo-random number generator1Krishna Myneni

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal