Slide 1

Slide 1 text

͋ͳͨͱཚ਺ੜ੒ͱ Java ୈेճ #ौ୩java 2015-03-07 @komiya_atsushi

Slide 2

Slide 2 text

͓·ͩΕ ʢ͓લ୭Αʁʣ

Slide 3

Slide 3 text

,0.*:""UTVTIJ !LPNJZB@BUTVTIJ

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Ad server and machine learning with Java

Slide 6

Slide 6 text

Random Number Generator

Slide 7

Slide 7 text

java.util.Random

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Random classes provided by JDK

Slide 10

Slide 10 text

Random classes provided by JDK • java.util.Random • java.security.SecureRandom • SecureRandom.getInstance("SHA1PRNG")   • java.util.concurrent.ThreadLocalRandom • ThreadLocalRandom.current()

Slide 11

Slide 11 text

Random classes provided by commons-math3

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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)

Slide 14

Slide 14 text

Comparisons

Slide 15

Slide 15 text

Concurrency of Random and ThreadLocalRandom

Slide 16

Slide 16 text

Concurrency of Random and ThreadLocalRandom 5ISFBE-PDBM3BOEPNJTBXFTPNF

Slide 17

Slide 17 text

Latency of 200,000,000 times random number generation

Slide 18

Slide 18 text

Latency of 200,000,000 times random number generation .FSTFOOF5XJTUFS JTGBTU 3BOEPNJTOPU GBTU

Slide 19

Slide 19 text

Conclusion

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

Thanks! Any questions?

Slide 22

Slide 22 text

8&`3&)*3*/( IUUQTKPCTGPSLXFMMDPNTNBSUOFXT PSDPOUBDUNF