xqRNG32 - "Lottery Machine" Random Number Generator

Discussion in 'Scientific Statistics Math' started by Karl-Uwe Frank, Nov 28, 2011.

  1. Today I like to introduce a new Pseudo Random Number Generator which I
    have invented over the last Weeks. Any constructive Critic or Comment is
    welcome.

    With a 32-bit Seed passed through it generates 32-bit Random Values,
    with minor Tweaks even 64-bit or perhaps 128-bit.

    The Results of xqRNG32 as 32-bit binary Output passes all empirical and
    statistical Tests for Randomness as there are FIPS-140-1, Diehard Test
    Battery, Frequency-, Poker-, Runs-, Long-Runs and Serial-Test, also
    Monte Carlo Value of Pi, Arithmetic Mean, Serial Correlation Coefficient
    and it generate a good Uniform Distribution of Zeros (0) and Ones(1).

    Also it passes the complete "TestU01 test battery", namely SmallCrush,
    Crush, BigCrush, Rabbit and Alphabit without showing any kind of
    recognisable weakness.

    The Idea behind is "porting" a mechanical Lottery Machine into a simple
    and fast Computer based Algorithm. So imagine there are 256 Tubes made
    of Metal, all of them lined up in a vertical Way one close to the other
    in a long Row, filled with numbered Table Tennis Balls.

    The functionality of the imaginary mechanical Lottery Machine would be
    as follows:

    #) Each Metal Tube will be filled with 232 Table Tennis Balls in a
    randomly fashion, while each Ball carries a printed HEX-Number from 0x00
    up to 0xFF.

    #) Horizontal beneath the Row of Tubes is a "Selector", carrying one
    Glass which has the exact same Diameter as one Tube.

    #) This Glass will now be constantly moved from left to right on the
    "Selector" under those Tubes until it comes to hold under one randomly
    selected Tube.

    #) From this Tube one Ball will drop into the Glass and thereafter will
    be placed on a Tray in Front of the Lottery Machine.

    #) After another 3 Times repeating this Procedure there are now 4 Balls
    with HEX-Numbers on the Tray.

    #) These concatenated 4 HEX-Numbers build the 32-bit Random Value as the
    Result.



    The C++ Listing of the imaginary "Lottery Machine" will read as follows:

    #---------------------------------------------------------------------
    /* xqRNG32, Pseudo Random Number Generator based on pqRNG */
    /* written by Karl-Uwe Frank, Copyright (c) 2011 Adverteam Limited (UK) */

    /*
    Free to use with or without modification and without a fee is granted
    only for private, research, academic or other non-commercial purposes.
    http://www.adverteam.co.uk/xqRNG32/LICENCE
    */

    static uint32_t seed, Q, P, R, X[256], aP[256], aR[256];

    int xqRNG32_Init() {
    int i;

    Q = seed ^ 0x11B923B;
    P = seed ^ 0x6FC55 + 0x1754;
    while ((P & 0x7) != 3) P++;
    R = (P >> 3);
    while ((R & 0x7) != 5) R++;

    for (i=0; i<256; i++) {
    Q = ((Q ^ R) * P);
    X = seed ^ ((Q ^ R) * P);
    aP = Q;
    while ((aP & 0x7) != 3) aP++;
    aR = (aP >> 3);
    while ((aR & 0x7) != 5) aR++;
    }

    Q = seed;
    Q = ((Q ^ R) * P);
    }


    unsigned int xqRNG32() {
    unsigned char Tube, ByteX[4];
    int i;

    for (i=0; i<4; i++) {
    Q = ((Q ^ R) * P);
    Tube = Q >> 24;
    X[Tube] = (X[Tube] ^ aR[Tube]) * aP[Tube];
    ByteX = X[Tube] >> 24;
    }

    return (ByteX[0] << 24 | ByteX[1] << 16 | ByteX[2] << 8 | ByteX[3]);
    }
    #---------------------------------------------------------------------


    Annotation: This PRNG should not be considered cryptographically secure.

    Further Information, Test Results and a documented C++ Source Code of
    xqRNG32 can be found at http://www.adverteam.co.uk/xqRNG32/

    Cheers,
    Karl-Uwe
     
    Karl-Uwe Frank, Nov 28, 2011
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.