Welcome to the Parallax Discussion Forums, sign-up to participate.

- 101.5K All Categories
- 812 Announcements
- 51 Propeller Code
- 22 PASM2/Spin2 (P2)
- 4 PASM/Spin (P1)
- 14 BASIC (for Propeller)
- 61 Forth
- 10 C/C++
- 2.8K Propeller 2
- 27.6K Propeller 1
- 18.9K BASIC Stamp
- 9 micro:bit
- 21.1K General Discussion
- 2K Learn with BlocklyProp
- 8.2K Robotics
- 124 Customer Projects
- 3.3K Accessories

## Comments

21,23312,192What code can you show me. I'm struggling to grok your descriptions.

1,808My PC has all the RAM it can take and it's much less than 4GB!

Program sent by PM

(and you'll know why when you see it).12,19212,19212,1921,808Many thanks for running the pair frequency tests, Evan. I think there is a tiny error in the code and this

misses out the FFFF_FFFF pair and it should be

I've run a program to find the frequencies of the FFFF_FFFF pairs and add them to your data, so there is no need for you to run the tests again.

1,808Pair frequencies for xoroshiro32++ [14,2,7,d]

Actual values and Expected binomialAll other frequencies not shown = 0

f0*0 + f1*1 + f2*2 + f3*3 + ... = 2^32-1 = full period

f0 + f1 + f2 + f3 + ... = 2^32-1 or 2^32

|Actual-Expected| values|Actual-Expected|/Expected valuesTruncated to f0-f12 to avoid division by zero

Comments[14,2,7,8] is the worst performer, as predicted by theory when d is exactly half the maximum possible rotation. The third table illustrates best how close most of the [a,b,c,d] quadruples are to the expected binomial, e.g. f0-f3 for [14,2,7,6] are each a better than 99.5% match and f1-f3 make up 92% of the total non-zero pair frequencies. Doing well in this test does not imply a quadruple will do the same in other tests.

1,808http://www.pcg-random.org/posts/a-quick-look-at-xoshiro256.html

12,192I'm not convince her concerns are entirely valid for what we are wanting though:

1: The progressiveness in state changes are hidden by the scrambler. That's the scrambler's job.

2: Algorithmically predictable is a given. Not a concern to us. This isn't for cryptography.

3: Invertible I don't understand. She seems focused on particular multipliers there. Maybe it's similar to predictability in that it can be hacked. I'm unsure how important this is, but it just sounds like it needs new constants. No shortage of those to choose from.

EDIT: I guess when she read "all-purpose" she interpreted that to mean for cryptographic uses too.

21,233As far as I understand these things, which is very little, she is pointing out a serious problem as in:

1) You have this PRNG whose output passses all maner of statistical tests of randomness. Which is sweet.

2) But if you happen to multiply it's output by the wrong numbers in your application, which is something one is likely to do, what you up end up with fails those statistical tests pretty quickly. Not so sweet.

I think I'll stick to JKISS32

12,19212,19221,233I thought the idea was use a multiplier that could be implemented as a couple of shifts and adds instead of an actual multiply. For the sake of speed. That would imply a multiplier with few 1 bits. In that case the search space for a better multiplier is much smaller.

It's fascinating to watch these PRNG "wars". Even if I don't understand the details:

Somebody dreams up a new PRNG.

Somebody else dreams up a new statistical test or other technique to show how crappy it is.

Rinse, repeat...

12,1921,808Thanks, Evan. I must have made a mistake with the zero distribution code. I didn't refer back to my working x86 version. We need zdist for two quads, ideally [14,2,7,5] and [14,2,7,6], to see if there is any real difference.

12,192Err, make that 4 + 4:

12,1921,808In case others are interested, the sixteen columns beginning with 6:15 are PractRand scores for every possible contiguous 8-bit sample of the 16-bit output. The first number is the msb and the second the lsb, with wrapping around from bit 0 to bit 15 where necessary. No quadruples have all 16 scores of 1G or more and overall quadruple [14,2,7,5] chosen for the XORO32 instruction does well.

1,808Evan, a small correction is are needed in your C code from

to

so that all 2^32 pairs are read. However, I doubt there is much need for further distribution tests.

Looking at the zero run frequency distributions or zfreq for short, I'm not convinced that zfreq(0) is calculated correctly. Having said that, zfreq(n)/zfreq(n+1) ~ 2.71828 = e for most values of n, including n = 0. In other words, the zero run distribution is an exponential decay function.

1,808But Seba is unfazed.

The paper explains the theoretical basis for the multipliers in the * and ** scramblers.

I'm wondering how often people will multiply millions of outputs by the same value of 57.

12,192It'd need written, in the prior loop, first.

I think it's correct already though. With the initial call to next_xoro(), there is a total of 2^32 random numbers generated. This should correctly count the wraparound pair.

Doh! I see now. I wasn't really trying to understand the code. The first loop is effectively building indexes into the array - which can be any 32-bit index.

1,808next_xoro() loop is correct as period is 2^32-1 and an initial iteration is needed to get the first "half pair" but the loop that increments freq values is definitely one short as 2^32 pairs must be read.

12,192Pity the do-while doesn't ascetically conform to common source formatting styles. That's probably the main reason I don't normally use it.

12,19212,192Looking at that particular Practrand report file, it hasn't gone far over the threshold. In fact I'm a little surprised by how narrow that one seems to be. I've force a rerun with no termination and it went right to the expected 1 GB without further fails. So I'll put that down to PractRand being a little too sensitive on a particular test.

12,192I'm happy to say that not only is 8-bit sampling a good way to do it, but the best way. Practrand internally works on bytes and bigger. But it is stated in the documentation that it is also most sensitive to the patterns in bit0 of the incoming bytes. This means that by shifting an 8-bit sampling window, on a per run basis, to align Practrand's bit0 to each bit of the generator we can test each output bit one by one.

12,19212,1921,808Each bit can be tested as the lsb of a byte but the other seven bits are also being tested.

Excellent!

Thanks Evan, it was worthwhile testing.

According to your byte theory, 4-bit samples should have better scores than 8-bit samples.