Most of the samplers in the library have very small states that are easy to compute. Some have computations that are more expensive, such as the LargeMeanPoissonSampler or the DiscreteProbabilityCollectionSampler.

However once the state is computed the only part of the state that changes is the RNG. I would like to suggest a way to copy samplers as something like:

DiscreteSampler newInstance(UniformRandomProvider)

The new instance would share all the private state of the first sampler except the RNG. This can be used for multi-threaded applications which require a new sampler per thread but sample from the same distribution.

A particular case in point is the as yet not integrated MarsagliaTsangWangSmallMeanPoissonSampler (see RNG-91 [1]) which has a "large" state [2] that takes a "long" time [3] to compute but is effectively immutable. This could be shared across instances saving memory for parallel application.

A copy instance would be almost zero set-up time and provide opportunity for caching of commonly used samplers.

Alex

[1] https://issues.apache.org/jira/browse/RNG-91

[2] kB, or possibly MB, of tabulated data

[3] Set-up cost for a Poisson sampler is in the order of 30 to 165 times as long as a SmallMeanPoissonSampler for a mean of 2 and 32. Note however that construction still takes only 1.1 and 4.5 microseconds for the "long" time.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to