random number generation and Monte Carlo simulation in C++

M

mescaline

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
 
C

Chris Theis

mescaline said:
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
 
G

Greg Schmidt

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.
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.
 
C

Cy Edmunds

mescaline said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,235
Latest member
Top Crypto Podcasts_

Latest Threads

Top