Thread: Prelude's random numbers tutorial

  1. #16
    FOX
    Join Date
    May 2005
    Posts
    188
    > But you should look the code above again to see if you really understood what the probability is for all possible results. I think you will find that all results have a 1 / (RAND_MAX + 1) probability. Not just 10.

    Code:
    std::rand() * 9.0 / RAND_MAX + 1;
    Is that the piece of code you were talking about?

    There's a world of difference between
    Code:
    std::rand() * 9.0 / RAND_MAX + 1
    and
    Code:
    std::rand() * 9.0 / (RAND_MAX  + 1)
    Only your second code snippet that involved a bucket_size works as expected.

  2. #17
    Registered User
    Join Date
    Jun 2005
    Posts
    47
    can u post a code that will make a random int and store it to x
    the random int are so confusing

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. Generatin Random Numbers
    By dantu1985 in forum C Programming
    Replies: 15
    Last Post: 08-13-2007, 01:21 AM
  3. Generating 100k to 1 million unique random numbers
    By Ariod in forum C Programming
    Replies: 4
    Last Post: 08-26-2005, 12:59 PM
  4. random number tutorial
    By 7stud in forum C++ Programming
    Replies: 3
    Last Post: 07-26-2005, 02:41 PM
  5. Random numbers (about the tutorial)
    By face_master in forum C++ Programming
    Replies: 3
    Last Post: 08-26-2001, 06:56 AM