Solved

Normal distribution generator

Posted on 1997-07-24
2
1,163 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Parsing XML instructions in Java/any other language.... 3 121
C++ question 3 74
C++ help/ Toy problem 19 52
How to add columns to a RAD Studio FMX grid at design time 1 30
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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

749 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