Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2006

    Unanswered: How random is RAND()?

    I recently used the RAND() function to select a random row from my database and a work collegue stated that they can't believe a computer can select a completely random value (or row in this case).

    When I asked why, they said that the function is based on an algorithm and so cannot be random. I argued that if the alogorithm is based on some random event then the result will be random.

    Not knowing exactly how the RAND() function selects its value I couldn't really argue my point.

    So, could anyone enlighten me on how the RAND() function in mysql selects its value.


  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    From what I remember its always been said that digital computers cannot generate truly random numbers, that if you want a computer to do that then you need to use some form of analogue input to generate truly random numbers. But most digital computers fake random numbers pretty well.

    I think the argument that that they don't generate true random numbers is true, but its good enough for most purposes. There is possibly an element of sophistry.. in as much the mechanism generate the number is truly random in all cases in all given events, but those limitations would probably only be significant in the most esoteric application. Having said that I've never tested the MySQL random function, only ones in different development environemnts.

    If you have suspicions that the random number generator isn't good enough then you need to test the random number generator to see if the results are random enough.

    I'd be reluctant to rely on a computer to draw random numbers for say a lottery, but most tests I've run over the years suggests the degree of randomness is good enough for my purposes.

    What have you seen that may make you believe that the random number generator isn't appropriate for your purposes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts