Solved

Normal distribution generator

Posted on 1997-07-24
2
1,147 Views
Last Modified: 2009-04-20
does anyone know where on the net i may find a source code
of a normal distibution generator class ?
i need to compile it on an open-VMS environment, so using
UNIX c++ libraries is out of the question.
tia /erel.
0
Comment
Question by:erel
2 Comments
 
LVL 4

Accepted Solution

by:
jos010697 earned 100 total points
ID: 1165823
Generate two uniformly distributed random numbers in
the interval [0, 1], say u and v; then

   x1= sqrt(-2*ln(u))*cos(2*pi*v)

and

   x2= sqrt(-2*ln(u))*sin(2*pi*v)

both are N(0,1). make your choice

Another (worse, but fast) method is:

generate 12 U(0, 1) random numbers; add them and
subtract 6, ie, sum(i= 1, 12)(x[i]])-6; don't expect much
accuracy near the extremes of the N(0,1) function value

kind regards,

Jos aka jos@and.nl


0
 

Expert Comment

by:baraka
ID: 1165824
You might try searching this address: http://www.karland.com/code/
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Want to delete all my personal data 13 138
how to understand recursion 12 218
Would like to move button in a function 3 72
I could not build boost code, 10 78
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now