Upgrade to Pro — share decks privately, control downloads, hide ads and more …

#渋谷java あなたと乱数生成とJava

#渋谷java あなたと乱数生成とJava

第十回 #渋谷java http://shibuya-java.connpass.com/event/11574/ での発表資料です。Java で乱数生成するときのお話をしました。

KOMIYA Atsushi

March 07, 2015
Tweet

More Decks by KOMIYA Atsushi

Other Decks in Programming

Transcript

  1. Random classes provided by JDK • java.util.Random • java.security.SecureRandom •

    SecureRandom.getInstance("SHA1PRNG")   • java.util.concurrent.ThreadLocalRandom • ThreadLocalRandom.current()
  2. Random classes provided by commons-math3 • MersenneTwister • most popular

    (?) random number generator • Well44497a • longer period than Mersenne Twister • ISAACRandom • a fast cryptographic pseudo-random number generator
  3. Random classes provided by commons-math3 • RandomDataGenerator supports sampling from

    various distributions • Beta / Binomial / Cauchy / ChiSquare / Exponential / F / Gamma / Hypergeometric / Pascal / Poisson / T / Weibull / Zipf • java.util.Random only supports sampling from Gaussian (normal distribution)
  4. If you need… • high concurrency one • use ThreadLocalRandom

    • very long-period & high quality one • use Well44497a • long-period & fast one • use MersenneTwister • cryptographically secure one • use SecureRandom