Results 1 to 5 of 5

Thread: Random Number Generation

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    10

    Random Number Generation

    hello ,veryone!
    I have a problem with number generator of IMSL 5.0 for C#.
    How can I find random number for normal distribution other than N(0,1) , for example N(29,5.2)? Which function should I use and how?
    Thanks in advance
    eagerly Regards

  2. #2
    Senior Member ed's Avatar
    Join Date
    Aug 2005
    Posts
    312
    You can use Random.NextNormal() or Random.NextNormalAR() to get a random number that fits N(0, 1). To fit this to N(m, s) first multiply the output by s then add m.

    N(m, s) = s * N(0, 1) + m.


    The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.

  3. #3
    Junior Member
    Join Date
    Aug 2009
    Posts
    10

    Smile thanks for your help, manager

    i have another question:
    int nObservations = 1000;
    Imsl.Stat.Random r = new Imsl.Stat.Random(123457);
    for (int i = 0; i < nObservations; i++)
    {
    double rn = r.NextNormal();
    }
    when the code run,why the variable rn has Negative phenomena?

  4. #4
    Senior Member ed's Avatar
    Join Date
    Aug 2005
    Posts
    312
    The Random.NextNormal() will give you a random number that falls into the normal distribution with mean=0 and std.dev=1, so about half of the values should be negative.


    The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.

  5. #5
    Junior Member
    Join Date
    Aug 2009
    Posts
    10

    thank you ,manager very much

    i get it!

Posting Permissions

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