Thread: looking for a random # generator

  1. #1
    w/ possion?
    Guest

    Unhappy looking for a random # generator

    I'm looking for a random number generator that can gives me random numbers in Possion dist'n. Can any one give a recomdation?
    thanks.

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    99
    Code:
    #include <time.h>
    #include <stdio.h>
    #define MAX 100
    
    int main()
    {
    int x;
    srand((unsigned)time());
    x=rand()%MAX;
    printf("The random number is %d",x);
    return 0;
    }

  3. #3
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Posts
    284

    Re: looking for a random # generator

    Originally posted by w/ possion?
    I'm looking for a random number generator that can gives me random numbers in Possion dist'n. Can any one give a recomdation?
    thanks.
    Have a look at the book Seminumerical Algorithms by Knuth.
    If you want to generate poisson with mean m_u note :
    If U(1)....U(n)... are i.i.d uniform on [0,1]
    and m is the smallest integer such that
    U(1)*........U(m)<= exp(-m_u)
    then m-1 is poisson.
    Last edited by pinko_liberal; 02-28-2003 at 03:09 AM.
    The one who says it cannot be done should never interrupt the one who is doing it.

  4. #4
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Posts
    284
    Originally posted by _Cl0wn_
    Code:
    #include <time.h>
    #include <stdio.h>
    #define MAX 100
    
    int main()
    {
    int x;
    srand((unsigned)time());
    x=rand()%MAX;
    printf("The random number is %d",x);
    return 0;
    }
    Doesn't generate from poisson.
    The one who says it cannot be done should never interrupt the one who is doing it.

  5. #5
    Black Mage Extraordinaire VegasSte's Avatar
    Join Date
    Oct 2002
    Posts
    167
    I'm looking for a random number generator that can gives me random numbers in Possion dist'n. Can any one give a recomdation?
    thanks.
    eh? What is possion dist'n?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How exactly does the random number generator work?
    By Finchie_88 in forum C++ Programming
    Replies: 6
    Last Post: 08-24-2007, 12:46 AM
  2. NAQ: Everything you never wanted to know about CPP
    By evildave in forum C Programming
    Replies: 21
    Last Post: 12-12-2005, 10:56 AM
  3. Testing Random Number Generator
    By Roaring_Tiger in forum C Programming
    Replies: 7
    Last Post: 08-12-2005, 12:48 AM
  4. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 07:18 AM
  5. Random number generator
    By Caze in forum C++ Programming
    Replies: 6
    Last Post: 12-03-2002, 08:10 AM