ScratchData LogoScratchData
Back to TheLogFather's profile

Long-period seeded pseudorandoms

THTheLogFather•Created June 30, 2015
Long-period seeded pseudorandoms
48
41
1325 views
View on Scratch

Description

*** UPDATE: added a 'Help!' button to explain about PRNGs... ------------------------------------------------------------------ Runs spectral and chi-squared tests on five pseudorandom number generators, including Scratch's built-in (probably OS-dependent), and one from the 1960's called "RANDU", which was very bad! -See https://en.wikipedia.org/wiki/RANDU to read all about that. My original seeded pseudorandom cycle project (below) used a simple formula to cycle through the values from -2147483645 to +2147483645 (except zero) in a well-defined order, but which *appeared* to be random. That sequence is retained within this project as "quick-cycle-1" (though it's much more efficient now). I've created another similar sequence which cycles through numbers from 1 to 4294967296(=2^32) in a random-looking order. This is called "quick-cycle-2" in here. *** It's worth noting that, since quick-cycle-2 is based on a power-of-two cycle, there are correlations in the low-order bits, which the chi-squared test can pick up with certain skips (e.g. try it with 2,2,2). I've brought these two together to make a *much* longer sequence, with a length of nearly 2^64 (>18 million million million). Because of floating-point rounding, this only returns integers in the range one to 500 billion (though there's a custom block to 'pick random' in a range, including as decimal values, for all three of the cycles). There are also blocks to extract the current seed info from the three cycles, so you can interrupt a cycle where it is, use it from a different seed, and then restart later on from the interrupted position.

Project Details

Project ID69020062
CreatedJune 30, 2015
Last ModifiedJuly 8, 2015
SharedJuly 7, 2015
Visibilityvisible
CommentsAllowed

Remix Information

Parent ProjectView Parent
Root ProjectView Root