Quantcast
Channel: Math.NET Numerics
Viewing all articles
Browse latest Browse all 971

New Post: Thread Safe Random Variate Generation

$
0
0
Hello,

Thanks for the response (and the awesome library). I am somewhat new to the ThreadLocal class and so was great to hear about this.

So I have a step in an MCMC routine that runs parallel across multiple threads (in theory they are completely independent). Right now I am using ThreadLocal<Mersenne> on each one and running that through. It seems to be reasonably fast in the sense that I don’t see any memory contentions at present. I think this might be ideal because the parameter for the poisson change on each call, so I can’t preallocate the poisson (but could the uniforms).

I think prefilling an array would be involve a lot more contention if all threads were using it relative to the threadlocal RNGs, but I may be mistaken.

Thanks again for the help!
Nigel


PS As a random factoid I recently found out that the .NET System.Random class has been coded incorrectly and so does not represent the actual algorithm they state in the documentation (see http://connect.microsoft.com/VisualStudio/feedback/details/634761/system-random-serious-bug, apparently they copied it wrong from numeric recipes). Not sure how big of an issue this is though.

Viewing all articles
Browse latest Browse all 971

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>