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.4k
#渋谷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
#JJUG Java における乱数生成器とのつき合い方
komiya_atsushi
5
4.3k
#JJUG Fork/Join フレームワークを効率的に正しく使いたい
komiya_atsushi
0
280
[#JSUG] SmartNews における container friendly な Spring Boot アプリケーション開発
komiya_atsushi
1
10k
Java のデータ圧縮ライブラリを極める #jjug_ccc #ccc_c7
komiya_atsushi
4
3.5k
#devsumi 自然言語処理・機械学習によるファクトチェック業務の支援
komiya_atsushi
1
3.5k
SmartNews Ads における機械学習の活用とその運用 #mlops
komiya_atsushi
3
18k
GBDT によるクリック率予測を高速化したい #オレシカナイト vol.4
komiya_atsushi
5
1.1k
Maven central repository の artifact をランキングする #渋谷java
komiya_atsushi
0
890
確率的データ構造を Java で扱いたい! #JJUG
komiya_atsushi
6
2k
Other Decks in Programming
See All in Programming
Felteで作る簡単フォームバリデーション
kubotak
1
130
Most Valuable Bug(?) ~インシデント未遂から得た学び~
tatsumiakahori
0
140
WordPress(再)入門 - 基礎知識・環境編
oleindesign
1
100
Domain-Driven Design (Tutorial)
hschwentner
11
15k
23年のJavaトレンドは?Quarkusで理解するコンテナネイティブJava
tatsuya1bm
1
110
TokyoR#103_DataProcessing
kilometer
0
350
tidy_rpart
bk_18
0
390
kakutanitalk2022_opening_act
shirotamaki
0
100
はてなリモートインターンシップ2022 インフラ 講義資料
hatena
4
2.1k
AWSとCPUのムフフな関係
cmdemura
0
440
Git Rebase
bkuhlmann
10
1.2k
Enumを自動で網羅的にテストしてみた
estie
0
1.2k
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
261
26k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
182
15k
Docker and Python
trallard
30
1.9k
Support Driven Design
roundedbygravity
88
8.9k
Large-scale JavaScript Application Architecture
addyosmani
499
110k
Pencils Down: Stop Designing & Start Developing
hursman
114
10k
Building Adaptive Systems
keathley
27
1.3k
Building Better People: How to give real-time feedback that sticks.
wjessup
346
17k
Why Our Code Smells
bkeepers
PRO
326
55k
Imperfection Machines: The Place of Print at Facebook
scottboms
254
12k
Statistics for Hackers
jakevdp
784
210k
Web Components: a chance to create the future
zenorocha
304
40k
Transcript
͋ͳͨͱཚੜͱ Java ୈेճ #ौ୩java 2015-03-07 @komiya_atsushi
͓·ͩΕ ʢ͓લ୭Αʁʣ
,0.*:""UTVTIJ
[email protected]
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