Solved

Normal distribution generator

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 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.

777 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