11.07.2015 Views

A Random Number Generator Test Suite for the C++ ... - ETH Zürich

A Random Number Generator Test Suite for the C++ ... - ETH Zürich

A Random Number Generator Test Suite for the C++ ... - ETH Zürich

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.18. n-block test5.18. n-block testThis test checks <strong>the</strong> average of subsequences, so called blocks. This is done by calculating<strong>the</strong> average of many sequences of uni<strong>for</strong>mly distributed random numbers (0 x i¡1) andincreasing a counter if <strong>the</strong> average of <strong>the</strong> sequence ¯x 1 2. This test is described in [28] anda implementation in Fortran can be found at http://www.physics.helsinki.fi/~vattulai/codes/nblocktest.fGenerate a sequence of n random numbers x 1 x 2 x ¢¡¢¡¢¡n where 0 x i¡1Calculate <strong>the</strong> average ¯x over <strong>the</strong> sequence, if ¯x 1 2 increase y 1Repeat <strong>the</strong> last two steps N timesCalculate <strong>the</strong> measured probability <strong>for</strong> ¯x 1 2 as y ¡with one degree of freedom on <strong>the</strong> y i2¥1 and per<strong>for</strong>m a χ 2 testyVattulainens criterion <strong>for</strong> failing: Each test is repeated 3 times, and <strong>the</strong> generator fails<strong>for</strong> fixed n if at least two out of three χ 2 failed, which should occur with a probabilityof about 3 400NExample:Lets generate 10 N¥sequences of n¥numbers8x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 ¯x0.84 0.394 0.783 0.798 0.912 0.198 0.335 0.768 0.6290.278 0.554 0.477 0.629 0.365 0.513 0.952 0.916 0.5860.636 0.717 0.142 0.607 0.0163 0.243 0.137 0.804 0.4130.157 0.401 0.13 0.109 0.999 0.218 0.513 0.839 0.4210.613 0.296 0.638 0.524 0.494 0.973 0.293 0.771 0.5750.527 0.77 0.4 0.892 0.283 0.352 0.808 0.919 0.6190.0698 0.949 0.526 0.0861 0.192 0.663 0.89 0.349 0.4660.0642 0.02 0.458 0.0631 0.238 0.971 0.902 0.851 0.4460.267 0.54 0.375 0.76 0.513 0.668 0.532 0.0393 0.4620.438 0.932 0.931 0.721 0.284 0.739 0.64 0.354 0.63Now we check <strong>the</strong> averages ¯x and get y 5 1¥and y y N 2¥5 1¥Constructor in n_block_test.hn_block_test(std::size_t n, std::size_t block_size)n number of blocksblock_size size of each block39

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!