Close

Stutter

A project log for PEAC Pisano with End-Around Carry algorithm

Add X to Y and Y to X, says the song. And carry on.

yann-guidon-ygdesYann Guidon / YGDES 02/11/2025 at 11:380 Comments

Playing a bit with PEAC w4 :

#include <stdint.h>

uint8_t PEAC_XC=1,  // the 5-bit part
        PEAC_Y=0;   // 4-bit

#include <stdio.h>

int main() {
  int i=0;

  do {
    printf("% 3d:   % 3d  % 3d \n", i, PEAC_XC, PEAC_Y);

    // split
    uint8_t PEAC_X = PEAC_XC & 15;
    PEAC_XC >>= 4;

    // PEAC scrambler
    PEAC_XC +=   PEAC_X + PEAC_Y;
    PEAC_Y   = ( PEAC_X + 0 ) & 15;

    i++;
  } while (i <= 136);

  return 0;
}

W4 is a maximal, not perfect, orbit so there are "only" 135 iterations. But the output sequence, either PEAC_Y or PEAC_XC, shows that some numbers repeat but only in consecutive pairs

        XC    Y
  0:     1    0 
  1:     1    1
  2:     2    1
  3:     3    2 
  4:     5    3 
  5:     8    5 
  6:    13    8 
  7:    21   13 
  8:    19    5 
  9:     9    3 
 10:    12    9 
 11:    21   12 
 12:    18    5 
 13:     8    2 
 14:    10    8 
 15:    18   10 
 16:    13    2 
 17:    15   13 
 18:    28   15 
 19:    28   12
 20:    25   12
 21:    22    9 
 22:    16    6 
 23:     7    0 
 24:     7    7
 25:    14    7
 26:    21   14 
 27:    20    5 
 28:    10    4 
 29:    14   10 
 30:    24   14 
 31:    23    8 
 32:    16    7 
 33:     8    0 
 34:     8    8 
 35:    16    8 
 36:     9    0 
 37:     9    9 
 38:    18    9 
 39:    12    2 
 40:    14   12

This "stutter" might be a sort of "signature" of a PEAC PRNG, which is why PEAC is better used as a scrambler IMHO.

Now, is this "stutter" a defect ? Not really. On the primary orbit of w4 above,

So in a maximal (and not perfect) orbit, there are some imbalances.

.

Discussions