Boost logo

Boost Users :

Subject: Re: [Boost-users] Cost of constructing models of RandomDistribution
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-02-19 10:36:57


AMDG

Robert Patterson wrote:
> I have a fairly large simulation code, that I need to get into a state
> in which I can multi-thread it. One of my problems is a global random
> number generator state.
>
> I am thinking that I should replace this global object with a collection
> of generator engines, one for each thread, which would be passed down by
> non-const reference from the top level of each thread to the places
> where random numbers are needed. In this case it seems best to pass
> around engines that model PseudoRandomNumberGenerator. In each place
> that I want a random number (I rarely need more than 1 or 2 at once or
> with the same parameters) I would then have to construct and use a
> RandomDistribution, such as uniform_int, exponential_distribution (or
> poisson, but that is a question for another day).
>
> This approach relies on these models of RandomDistribution being fairly
> cheap to construct. I cannot see any reason why this should not be the
> case, but equally I cannot see any promise in the docs that they will be
> cheap to construct.
>
> Am I proposing to use the library in a sensible way?
>

None of the distributions do any expensive precomputation.
The exponential and uniform distributions don't need any
precomputation. Some of the other distributions, like the
binomial and poisson distributions might have some
precomputation in the future, but you probably don't want
to use them now anyway, as they are very inefficient.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net