Solved

Normal distribution generator

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

707 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

13 Experts available now in Live!

Get 1:1 Help Now