Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
#渋谷java あなたと乱数生成とJava
Search
KOMIYA Atsushi
March 07, 2015
Programming
1
1.8k
#渋谷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
5.4k
#JJUG Fork/Join フレームワークを効率的に正しく使いたい
komiya_atsushi
0
530
[#JSUG] SmartNews における container friendly な Spring Boot アプリケーション開発
komiya_atsushi
1
11k
Java のデータ圧縮ライブラリを極める #jjug_ccc #ccc_c7
komiya_atsushi
4
5.1k
#devsumi 自然言語処理・機械学習によるファクトチェック業務の支援
komiya_atsushi
1
4.6k
SmartNews Ads における機械学習の活用とその運用 #mlops
komiya_atsushi
3
20k
GBDT によるクリック率予測を高速化したい #オレシカナイト vol.4
komiya_atsushi
5
1.4k
Maven central repository の artifact をランキングする #渋谷java
komiya_atsushi
0
1.5k
確率的データ構造を Java で扱いたい! #JJUG
komiya_atsushi
6
2.3k
Other Decks in Programming
See All in Programming
Stay Hacker 〜九州で生まれ、Perlに出会い、コミュニティで育つ〜
pyama86
1
320
『HOWはWHY WHATで判断せよ』 〜『ドメイン駆動設計をはじめよう』の読了報告と、本質への探求〜
panda728
PRO
5
1.1k
Snowflake リリースに注意を払いたくなる話
masaaya
0
100
Private APIの呼び出し方
kishikawakatsumi
2
830
HTTPじゃ遅すぎる! SwitchBotを自作ハブで動かして学ぶBLE通信
occhi
0
230
問題の見方を変える「システム思考」超入門
panda_program
0
190
知られているようで知られていない JavaScriptの仕様 4選
syumai
0
520
AI 時代だからこそ抑えたい「価値のある」PHP ユニットテストを書く技術 #phpconfuk / phpcon-fukuoka-2025
shogogg
1
410
Web エンジニアが JavaScript で AI Agent を作る / JSConf JP 2025 sponsor session
izumin5210
3
550
FlutterKaigi 2025 システム裏側
yumnumm
0
750
最新のDirectX12で使えるレイトレ周りの機能追加について
projectasura
0
160
レイトレZ世代に捧ぐ、今からレイトレを始めるための小径
ichi_raven
0
190
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Faster Mobile Websites
deanohume
310
31k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
Building Applications with DynamoDB
mza
96
6.7k
Producing Creativity
orderedlist
PRO
348
40k
How to Ace a Technical Interview
jacobian
280
24k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
24
1.5k
GraphQLとの向き合い方2022年版
quramy
49
14k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
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