Thread: Came back to random numbers and got decent randomness

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,735

    Came back to random numbers and got decent randomness

    Haven't been able to install dieharder yet due a multiple definition error that pops up an uncounted times (far too many for to bother with that) however the result of seed 0 with
    gcc -D RNG_PIC %f && ./a.out > pic.ppm && eog pic.ppm
    brought a decent result, no sign of any lines, tried it a few times with time & clock and didn't see any tears like I sometimes do with the rand_r()
    Code:
    size_t my_rng( size_t x )
    {
    	size_t n;
    	size_t const move = (bitsof(size_t)/4);
    	size_t const add = (9999 << move) | 9999;
    	x += add + 33333;
    	n = x >> 1;
    	x *= n;
    	return x + 777;
    }
    Are there any alternatives to dieharder?
    For anyone looking for my previous related thread (myself included) here's the link:
    Seeded/Seedless random number

    Edit: Noticed I made a mistake in the code while I was editing it prior to the tests (which makes it interesting that it still produced a noisy result), so here is the version without the mistake, same noisy result but should be better as far as the bits go:
    Code:
    size_t my_rng( size_t x )
    {
    	size_t n;
    	size_t const move = (bitsof(size_t)/4);
    	size_t const add = (9999 << move) | 9999;
    	x += add + 33333;
    	n = x >> move;
    	x *= n;
    	return x + 777;
    }
    Learned of testu01 which seemed to install fine so after getting something to eat I'm gonna look through it's documentation to see how I should use it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Scale back size of Numbers while maintaining proportion
    By kerrymaid in forum C Programming
    Replies: 5
    Last Post: 10-23-2011, 01:31 PM
  2. Replies: 4
    Last Post: 11-16-2004, 07:29 AM
  3. Replies: 3
    Last Post: 07-24-2002, 08:46 AM
  4. random number - replaying back.. pls help!
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 01-18-2002, 02:34 AM

Tags for this Thread