Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
#渋谷java あなたと乱数生成とJava
KOMIYA Atsushi
March 07, 2015
Programming
1
1.2k
#渋谷java あなたと乱数生成とJava
第十回 #渋谷java
http://shibuya-java.connpass.com/event/11574/
での発表資料です。Java で乱数生成するときのお話をしました。
KOMIYA Atsushi
March 07, 2015
Tweet
Share
More Decks by KOMIYA Atsushi
See All by KOMIYA Atsushi
komiya_atsushi
5
3.5k
komiya_atsushi
0
150
komiya_atsushi
1
10k
komiya_atsushi
4
2.6k
komiya_atsushi
1
2.7k
komiya_atsushi
4
15k
komiya_atsushi
5
1k
komiya_atsushi
0
600
komiya_atsushi
6
1.8k
Other Decks in Programming
See All in Programming
dnskimo
7
1.4k
fei0203018
0
160
daipresents
10
3.6k
tmyk110
1
170
chatii
2
290
o0h
PRO
0
340
yattom
32
11k
daipresents
0
340
manfredsteyer
PRO
1
120
progate
2
520
doyaaaaaken
1
330
daiki_0816
0
190
Featured
See All Featured
samanthasiow
58
6.4k
stephaniewalter
262
11k
mongodb
23
3.9k
qrush
285
19k
nonsquared
81
3.4k
holman
462
280k
holman
288
130k
jonyablonski
22
1.3k
davidbonilla
70
3.6k
bkeepers
PRO
322
53k
destraynor
221
47k
frogandcode
128
20k
Transcript
͋ͳͨͱཚੜͱ Java ୈेճ #ौ୩java 2015-03-07 @komiya_atsushi
͓·ͩΕ ʢ͓લ୭Αʁʣ
,0.*:""UTVTIJ !LPNJZB@BUTVTIJ
None
Ad server and machine learning with Java
Random Number Generator
java.util.Random
None
Random classes provided by JDK
Random classes provided by JDK • java.util.Random • java.security.SecureRandom •
SecureRandom.getInstance("SHA1PRNG") • java.util.concurrent.ThreadLocalRandom • ThreadLocalRandom.current()
Random classes provided by commons-math3
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
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)
Comparisons
Concurrency of Random and ThreadLocalRandom
Concurrency of Random and ThreadLocalRandom 5ISFBE-PDBM3BOEPNJTBXFTPNF
Latency of 200,000,000 times random number generation
Latency of 200,000,000 times random number generation .FSTFOOF5XJTUFS JTGBTU 3BOEPNJTOPU
GBTU
Conclusion
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
Thanks! Any questions?
8&`3&)*3*/( IUUQTKPCTGPSLXFMMDPNTNBSUOFXT PSDPOUBDUNF