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.8k
1
Share
#渋谷java あなたと乱数生成とJava
第十回 #渋谷java
http://shibuya-java.connpass.com/event/11574/
での発表資料です。Java で乱数生成するときのお話をしました。
KOMIYA Atsushi
March 07, 2015
More Decks by KOMIYA Atsushi
See All by KOMIYA Atsushi
#JJUG Java における乱数生成器とのつき合い方
komiya_atsushi
5
5.5k
#JJUG Fork/Join フレームワークを効率的に正しく使いたい
komiya_atsushi
0
580
[#JSUG] SmartNews における container friendly な Spring Boot アプリケーション開発
komiya_atsushi
1
11k
Java のデータ圧縮ライブラリを極める #jjug_ccc #ccc_c7
komiya_atsushi
4
5.3k
#devsumi 自然言語処理・機械学習によるファクトチェック業務の支援
komiya_atsushi
1
4.8k
SmartNews Ads における機械学習の活用とその運用 #mlops
komiya_atsushi
3
21k
GBDT によるクリック率予測を高速化したい #オレシカナイト vol.4
komiya_atsushi
5
1.4k
Maven central repository の artifact をランキングする #渋谷java
komiya_atsushi
0
1.6k
確率的データ構造を Java で扱いたい! #JJUG
komiya_atsushi
6
2.4k
Other Decks in Programming
See All in Programming
Nuxt Server Components
wattanx
0
230
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
1.2k
ネイティブアプリとWebフロントエンドのAPI通信ラッパーにおける共通化の勘所
suguruooki
0
230
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
16
3.5k
Strategy for Finding a Problem for OSS: With Real Examples
kibitan
0
130
テレメトリーシグナルが導くパフォーマンス最適化 / Performance Optimization Driven by Telemetry Signals
seike460
PRO
2
200
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
530
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
130
Geminiをパートナーに神社DXシステムを個人開発した話(いなめぐDX 開発振り返り)
fujiba
0
130
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.5k
PHPのバージョンアップ時にも役立ったAST(2026年版)
matsuo_atsushi
0
280
KagglerがMixSeekを触ってみた
morim
0
360
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
510
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
27
3.4k
エンジニアに許された特別な時間の終わり
watany
106
240k
Building an army of robots
kneath
306
46k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
500
Paper Plane
katiecoart
PRO
1
48k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
490
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
200
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
97
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