Need to find/build best randomizer ever

  • ivel236
    10th Apr 2016 Member 0 Permalink
    I am making something that requires a very good randomizer but cannot find one that doesn't have some sort of bias in one output or another. Typically the main thing I see is that in liquid/gas randomizers there is always a bias to the left or right because TPT actually renders from left to right. (and up to down)

    I was thinking that perhaps if it hasn't been done already you could combine multiple random data streams with each other and switch around their most significant bits? This could possibly negate the left/right bias and make the output closer resemble the random numbers the TPT code is generating.

    Edited once by ivel236. Last: 10th Apr 2016
  • boxmein
    10th Apr 2016 Former Staff 0 Permalink
    @ivel236 (View Post)
    It doesn't render left-to-right or up-to-down - it updates each particle in the order they were created. However... particles themselves run their reaction left-to-right, then top-to-down.

    As for random numbers sampled from the system - rand() is sufficient for our non-cryptographic purposes. It's a pretty good normally distributed random generator in the GNU C and Microsoft Visual C++ Runtime cases.
    Edited once by boxmein. Last: 10th Apr 2016
  • ivel236
    11th Apr 2016 Member 0 Permalink
    When I said "render" I guess I meant "update". Anyway I am fairly certain this causes some sort of bias when it comes to moving particles. I went through with my idea and combined the outputs of multiple randomizers and the results are pretty good.


    Each 8-bit randomizer has its bit significance shifted like so:

    001 002 004 008 016 032 064 128
    128 001 002 004 008 016 032 064
    064 128 001 002 004 008 016 032
    032 064 128 001 002 004 008 016
    016 032 064 128 001 002 004 008
    008 016 032 064 128 001 002 004
    004 008 016 032 064 128 001 002
    002 004 008 016 032 064 128 001

    All the outputs are then XORred together into one 8-bit value.

    My hope is that this will offset any kind of left/right bias in the movement of the particles that generate the output; and thus get closer to that glorious system - rand() function embedded in the C++.

    Next I want to be able to generate a random number between a lower and upper limit while still utilizing the 0-255 output. Does anyone know of an efficient algorithm to do this?
    Edited 3 times by ivel236. Last: 11th Apr 2016