Results 1 to 7 of 7

Thread: Random Number Stream Generator

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Lesser Knight
    Join Date
    Sep 2006
    Posts
    41

    Default Random Number Stream Generator

    OK, I've finished a class for a random number stream generator

    Features are:
    - You may instantiate multiple number streams
    - Repeatability, based on 32bit int number seeds
    - the PRNG is a Mersenne Twist algorithm, yielding a good distribution
    - Various random functions:
    -- rand() returns a 32bit int between 0 and 0xffffffff
    -- normalized() returns a float between 0.0 and 1.0
    -- even() returns bool (either true or false)
    -- deviated returns, well, potentially ANY number, with the output being distributed in a bell curve based on a median and standard deviation that you supply the function.

    If desired, I will implement state saving / loading features, though I don't know if this is necessary.

    I don't foresee speed being an issue; on my machine (an Athlon XP 1700+) I can easily generate a few million deviated random numbers (they take far longer than the other varieties) in a second or two.


    If people are OK with this, I'd like to incorporate it into ClanLib, as I believe such a system is rather useful. I'll have a patch ready for approval in a day or two.

    ...Chambers

    PS In the archive, you will find 3 files: a header file, an implementation file and a test file. The test takes some user input, and validates the PRNG distributing results correctly.
    Attached Files Attached Files

Similar Threads

  1. A couple of random queries
    By Dan in forum Funeral Quest
    Replies: 7
    Last Post: 06-30-2003, 09:33 AM

Bookmarks

Bookmarks

Posting Permissions

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