Dieharder random test suite - dziwne wyniki testów

0

Stworzyłem plik txt z outputem poniższego generatora liczb pseudolosowych (LCG - 2500000 próbek)

    import numpy as np
    
    class LCG(object):
    
        UZERO: np.uint32 = np.uint32(0)
        UONE : np.uint32 = np.uint32(1)
    
        def __init__(self, seed: np.uint32, a: np.uint32, c: np.uint32) -> None:
            self._seed: np.uint32 = np.uint32(seed)
            self._a   : np.uint32 = np.uint32(a)
            self._c   : np.uint32 = np.uint32(c)
    
        def next(self) -> np.uint32:
            self._seed = self._a * self._seed + self._c
            return self._seed
    
        def seed(self) -> np.uint32:
            return self._seed
    
        def set_seed(self, seed: np.uint32) -> np.uint32:
            self._seed = seed
    
        def skip(self, ns: np.int32) -> None:
            """
            Signed argument - skip forward as well as backward
    
            The algorithm here to determine the parameters used to skip ahead is
            described in the paper F. Brown, "Random Number Generation with Arbitrary Stride,"
            Trans. Am. Nucl. Soc. (Nov. 1994). This algorithm is able to skip ahead in
            O(log2(N)) operations instead of O(N). It computes parameters
            A and C which can then be used to find x_N = A*x_0 + C mod 2^M.
            """
    
            nskip: np.uint32 = np.uint32(ns)
    
            a: np.uint32 = self._a
            c: np.uint32 = self._c
    
            a_next: np.uint32 = LCG.UONE
            c_next: np.uint32 = LCG.UZERO
    
            while nskip > LCG.UZERO:
                if (nskip & LCG.UONE) != LCG.UZERO:
                    a_next = a_next * a
                    c_next = c_next * a + c
    
                c = (a + LCG.UONE) * c
                a = a * a
    
                nskip = nskip >> LCG.UONE
    
            self._seed = a_next * self._seed + c_next
    
    
    #%%
    np.seterr(over='ignore')
    
    a = np.uint32(1664525)
    c = np.uint32(1013904223)
    seed = np.uint32(1)
    
    rng = LCG(seed, a, c)
    q = [rng.next() for _ in range(0, 2500000)]

Zapisałem plik używając poniższego kodu w Jupyter Notebook:

First cell

    %%capture cap --no-stderr
    print(q)

Second cell

    with open('output5.txt', 'w') as f:
        f.write(cap.stdout)

Następnie użyłem Dieharder suite do przeprowadzenia testów w następujący sposób:

    dieharder -f output5.txt -a

Nie jestem do końca pewien, czy testy wykonywane są rzeczywiście na moim pliku.
Próbka 2,5mln wygenerowanych liczb ma około 30mb.
Prawie każdy test zakończył się sukcesem, co mnie trochę dziwi.

Poniżej wrzucam wynik z terminala:

Jestem trochę zmieszany, ponieważ "rng name" to MT19937 - to nie jest nazwa mojego rng i nie wiem skąd się wzieła, natomiast "filename" - "output5.txt" to mój plik. Nie wiem, czy testy wykonywane są na moim pliku i czy ten plik jest odpowiedni do Dieharder Suite - Byłoby miło, gdyby ktoś rzucił na to okiem.

title

2

Pierwszym twoim krokiem powinno być przeczytanie dokumentacji? Jako że najprawdopodobniej nie jesteś newbie to powinien być twój pierwszy odruch.
Nigdy nie używałem tego narzędzia, ale w 5 minut ustaliłem, że źle używasz narzędzia.

Ubuntu Manpage: dieharder - dieharder OPTIONS

dieharder OPTIONS

   -a runs all the tests with standard/default options to create a
          user-controllable  report.   To control the formatting of the report, see -D below.
          To control the power of the test (which  uses  default  values  for  tsamples  that
          cannot  generally  be  varied  and  psamples which generally can) see -m below as a
          "multiplier" of the default number of psamples (used only in a -a run).

   -f filename - generators 201 or 202 permit either raw binary or
          formatted ASCII numbers to be read in from a file for testing.  generator 200 reads
          in  raw  binary  numbers from stdin.  Note well: many tests with default parameters
          require a lot of rands!  To see  a  sample  of  the  (required)  header  for  ASCII
          formatted input, run

                   dieharder -o -f example.input -t 10

          and  then  examine  the  contents  of example.input.  Raw binary input reads 32 bit
          increments of the specified data stream.  stdin\_input\_raw accepts a pipe from a raw
          binary stream.

Czyli uruchomiłeś testy ze standardowymi ustawieniami.
Wczytywanie z pliku, jest przeznaczone dla specyficznych generatorów (prawdopodobnie te 201 i 202 to są generatory czytające dane z pliku).
Najwyraźniej jeśli nie wybierzesz tych generatorów dane wejściowe są nieistotne i faktycznie testujesz jeden z wbudowanych generatorów, z logów wynika że jest to mt19937

Na dole dokumentacji są przykłady:
Ubuntu Manpage: dieharder - Examples

EXAMPLES

   To demonstrate all tests, run on the default GSL rng, enter:

     dieharder -a

   To demonstrate a test of an external generator of a raw binary stream  of  bits,  use  the
   stdin (raw) interface:

     cat /dev/urandom | dieharder -g 200 -a

   To use it with an ascii formatted file:

     dieharder -g 202 -f testrands.txt -a

   (testrands.txt should consist of a header such as:

    #==================================================================
    # generator mt19937_1999  seed = 1274511046
    #==================================================================
    type: d
    count: 100000
    numbit: 32
    3129711816
      85411969
    2545911541

   etc.).

   To use it with a binary file

     dieharder -g 201 -f testrands.bin -a

   or

     cat testrands.bin | dieharder -g 200 -a

   An  example  that  demonstrates  the  use  of  "prefixes" on the output lines that make it
   relatively easy to filter off the different parts of the output report and  chop  them  up
   into numbers that can be used in other programs or in spreadsheets, try:

     dieharder -a -c ',' -D default -D prefix

Chyba oczywiste jest, że interesuje cię ta część:

   To use it with an ascii formatted file:

     dieharder -g 202 -f testrands.txt -a

A jescze na koniec popatrz na to:

$ dieharder -g -1
#=============================================================================#
#            dieharder version 3.31.1 Copyright 2003 Robert G. Brown          #
#=============================================================================#
#    Id Test Name           | Id Test Name           | Id Test Name           #
#=============================================================================#
|   000 borosh13            |001 cmrg                |002 coveyou             |
|   003 fishman18           |004 fishman20           |005 fishman2x           |
|   006 gfsr4               |007 knuthran            |008 knuthran2           |
|   009 knuthran2002        |010 lecuyer21           |011 minstd              |
|   012 mrg                 |013 mt19937             |014 mt19937_1999        |
|   015 mt19937_1998        |016 r250                |017 ran0                |
|   018 ran1                |019 ran2                |020 ran3                |
|   021 rand                |022 rand48              |023 random128-bsd       |
|   024 random128-glibc2    |025 random128-libc5     |026 random256-bsd       |
|   027 random256-glibc2    |028 random256-libc5     |029 random32-bsd        |
|   030 random32-glibc2     |031 random32-libc5      |032 random64-bsd        |
|   033 random64-glibc2     |034 random64-libc5      |035 random8-bsd         |
|   036 random8-glibc2      |037 random8-libc5       |038 random-bsd          |
|   039 random-glibc2       |040 random-libc5        |041 randu               |
|   042 ranf                |043 ranlux              |044 ranlux389           |
|   045 ranlxd1             |046 ranlxd2             |047 ranlxs0             |
|   048 ranlxs1             |049 ranlxs2             |050 ranmar              |
|   051 slatec              |052 taus                |053 taus2               |
|   054 taus113             |055 transputer          |056 tt800               |
|   057 uni                 |058 uni32               |059 vax                 |
|   060 waterman14          |061 zuf                 |                        |
#=============================================================================#
|   200 stdin_input_raw     |201 file_input_raw      |202 file_input          |
|   203 ca                  |204 uvag                |205 AES_OFB             |
|   206 Threefish_OFB       |207 XOR (supergenerator)|208 kiss                |
|   209 superkiss           |                        |                        |
#=============================================================================#
|   400 R_wichmann_hill     |401 R_marsaglia_multic. |402 R_super_duper       |
|   403 R_mersenne_twister  |404 R_knuth_taocp       |405 R_knuth_taocp2      |
#=============================================================================#
|   500 /dev/random         |501 /dev/urandom        |                        |
#=============================================================================#
#=============================================================================#

I już wszystko powinno być jasne.

1 użytkowników online, w tym zalogowanych: 0, gości: 1