By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 1,983 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

random number generation and Monte Carlo simulation in C++

P: n/a
hi,

i'm new to C++

could anyone refer me to a good site / good examples of random
numbers?

in particular including:
1) the commnds to obtain normally and exponenetially distributed r
numbers
2) how the above types of random numbers are generated from uniform
rvs

i need to generate random numbers, normal and exponenetial, and then
use them in a Monte Carlo simulation to obtain their mean and
variance.
So any Monte Carlo code direction would also be appreciated.

I crudely know how to do this (because i've done it matlab) but I am
aiming to be professional in C++ and would like to do the above
generation in a sophisiticated way.

thanks
m
Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ap*****@columbia.edu (mescaline) writes:
hi,

i'm new to C++

could anyone refer me to a good site / good examples of random
numbers?

[snip]

http://www.boost.org/libs/random/
Jul 19 '05 #2

P: n/a

"mescaline" <ap*****@columbia.edu> wrote in message
news:e5**************************@posting.google.c om...
hi,

i'm new to C++

could anyone refer me to a good site / good examples of random
numbers?
Check out for example the boost library.

in particular including:
1) the commnds to obtain normally and exponenetially distributed r
numbers
There are no such commands available. The "only" thing available is a random
generator which delivers (more or less) uniform numbers but this is enough.
2) how the above types of random numbers are generated from uniform
rvs
To obtain a normal distribution check out the Box Mueller formula and for
exponential distributed numbers you can easily use the transformation
method.

i need to generate random numbers, normal and exponenetial, and then
use them in a Monte Carlo simulation to obtain their mean and
variance.
So any Monte Carlo code direction would also be appreciated.

I crudely know how to do this (because i've done it matlab) but I am
aiming to be professional in C++ and would like to do the above
generation in a sophisiticated way.


You could go ahead implementing a base class like a CRandomKernel which
includes a good random generator for a uniform distribution. This base class
might also implement for example a rejection method or other sampling
algorithms and for a specialized distribution you might derive and supply
your specialized PDF or you could solve it providing function pointers.

HTH
Chris

Jul 19 '05 #3

P: n/a
On Wed, 10 Sep 2003 09:32:47 +0200, "Chris Theis"
<Ch*************@nospam.cern.ch> wrote:

"mescaline" <ap*****@columbia.edu> wrote in message
news:e5**************************@posting.google. com...
hi,

i'm new to C++

could anyone refer me to a good site / good examples of random
numbers?


Check out for example the boost library.


That is indeed a good site to look at. A good example of a random
number is 65481.
in particular including:
1) the commnds to obtain normally and exponenetially distributed r
numbers


There are no such commands available. The "only" thing available is a random
generator which delivers (more or less) uniform numbers but this is enough.


In fact the boost random number library includes a number of
distribution types, normal and exponential being two of them.

--
Greg Schmidt (gr***@trawna.com)
Trawna Publications (http://www.trawna.com/)
Jul 19 '05 #4

P: n/a
"mescaline" <ap*****@columbia.edu> wrote in message
news:e5**************************@posting.google.c om...
hi,

i'm new to C++

could anyone refer me to a good site / good examples of random
numbers?

in particular including:
1) the commnds to obtain normally and exponenetially distributed r
numbers
2) how the above types of random numbers are generated from uniform
rvs

i need to generate random numbers, normal and exponenetial, and then
use them in a Monte Carlo simulation to obtain their mean and
variance.
So any Monte Carlo code direction would also be appreciated.

I crudely know how to do this (because i've done it matlab) but I am
aiming to be professional in C++ and would like to do the above
generation in a sophisiticated way.

thanks
m


Click on the link in my sig and find the UVS library.

--
Cy
http://home.rochester.rr.com/cyhome/
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.