开发者

Need a fast Java beta distribution random number generator

开发者 https://www.devze.com 2022-12-20 14:04 出处:网络
I need to generate random numbers that have a beta distribution in some speed critical code.Currently I\'m using the BetaRandomVariable() class from the numerics4j library - but currently repres开发者

I need to generate random numbers that have a beta distribution in some speed critical code. Currently I'm using the BetaRandomVariable() class from the numerics4j library - but currently repres开发者_StackOverflowents about 95% of my code's CPU usage!

Can anyone recommend a faster way to generate these random numbers?


You can look at the NumPy random number generators. They're in C, but the code is relatively readable and permissively licensed, so they can easily be ported to Java. You don't need to port the basic Mersenne Twister generator as Java has one in its standard library, only the code that takes numbers form the Mersenne Twister and converts it to a beta distribution. I've ported most of the NumPy random number generators to D and found them to be very efficient, and you'll probably find the same in Java.


A faster Java implementation of the Mersenne Twister algorithm which I have found useful in a number of applications is available from here: http://www.cs.gmu.edu/~sean/research/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号