Pergunta

Preciso gerar números aleatórios que tenham uma distribuição beta em algum código crítico de velocidade. Atualmente, estou usando a classe bearandomvariable () da biblioteca numeric4j - mas atualmente representa cerca de 95% do uso da CPU do meu código!

Alguém pode recomendar uma maneira mais rápida de gerar esses números aleatórios?

Foi útil?

Solução

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.

Outras dicas

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/

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top