how to generate random data for a normal distribution

Discussion in 'C++' started by Yudan YI \(OSU\), Feb 24, 2005.

  1. I want to generate random data from a normal distribution, while I checked
    the functions, and I found rand(), which returns a pseudorandom integer
    between zero and RAND_MAX. I am not sure how to use this function to
    generate my random data from a normal distribution.

    Thanks
    Yudan
     
    Yudan YI \(OSU\), Feb 24, 2005
    #1
    1. Advertising

  2. Yudan YI \(OSU\)

    James Rafter Guest

    This is not really a C++ question. But...

    Google 'Numerical Recipes'. There's a NR in C, C++, Fortran, etc. The
    C one is available online.
    but the C++ one is not.

    Chapter 7 of the C book will show you what you need to do this from
    scratch.
    Perhaps others can recommend libraries if you don't want to do that.
     
    James Rafter, Feb 24, 2005
    #2
    1. Advertising

  3. Yudan YI (OSU) wrote:
    > I want to generate random data from a normal distribution, while I

    checked
    > the functions, and I found rand(), which returns a pseudorandom

    integer
    > between zero and RAND_MAX. I am not sure how to use this function to
    > generate my random data from a normal distribution.


    Have a look at the random number generator library at Boost
    (<http://www.boost.org/>): this library supports several
    distributions and the random number generators also have a
    few other advantages of the typical standard library
    implementations of 'rand()'. A library with essentially this
    interface is also part of the standard library technical
    report which includes candidates for future standard library
    extensions.
    --
    <mailto:> <http://www.dietmar-kuehl.de/>
    <http://www.contendix.com> - Software Development & Consulting
     
    Dietmar Kuehl, Feb 24, 2005
    #3
  4. Yudan YI \(OSU\)

    hautrub Guest

    Hi,

    Is there any other links to random number generator?

     
    hautrub, Feb 24, 2005
    #4
  5. Yudan YI \(OSU\)

    rossum Guest

    On 23 Feb 2005 22:55:40 -0800, "James Rafter" <>
    wrote:

    >This is not really a C++ question. But...
    >
    >Google 'Numerical Recipes'. There's a NR in C, C++, Fortran, etc. The
    >C one is available online.
    >but the C++ one is not.
    >
    >Chapter 7 of the C book will show you what you need to do this from
    >scratch.
    >Perhaps others can recommend libraries if you don't want to do that.


    The C version is here:
    http://www.library.cornell.edu/nr/cbookcpdf.html

    Beware of the code style, it is a good example of the saying "A real
    programmer can write FORTRAN in any language."

    rossum

    --

    The ultimate truth is that there is no Ultimate Truth
     
    rossum, Feb 24, 2005
    #5
  6. hautrub wrote:
    > Is there any other links to random number generator?


    Probably but none that I'm immediately aware of without search
    the Internet. Well, you can look at the technical report on
    library extension at the standard C++ site but this is
    essentially the Boost library in a different namespace and,
    AFAIK, without a ready implementation.

    However, out of curiosity: what desires in random number
    generation leaves the Boost random number generator library
    unsatisfied?
    --
    <mailto:> <http://www.dietmar-kuehl.de/>
    <http://www.contendix.com> - Software Development & Consulting
     
    Dietmar Kuehl, Feb 25, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tan Thuan Seah
    Replies:
    3
    Views:
    11,242
    Cy Edmunds
    Oct 14, 2004
  2. PCHOME
    Replies:
    3
    Views:
    2,221
    Lawrence Kirby
    Jun 23, 2005
  3. Verbal Kint
    Replies:
    10
    Views:
    669
    Keith Thompson
    Jun 30, 2007
  4. thinke365
    Replies:
    11
    Views:
    2,330
    Robert Kern
    Jan 25, 2010
  5. Luca Cerone
    Replies:
    29
    Views:
    1,413
    lucacerone
    Feb 21, 2012
Loading...

Share This Page