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.7k
#渋谷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.3k
#JJUG Fork/Join フレームワークを効率的に正しく使いたい
komiya_atsushi
0
510
[#JSUG] SmartNews における container friendly な Spring Boot アプリケーション開発
komiya_atsushi
1
11k
Java のデータ圧縮ライブラリを極める #jjug_ccc #ccc_c7
komiya_atsushi
4
5k
#devsumi 自然言語処理・機械学習によるファクトチェック業務の支援
komiya_atsushi
1
4.5k
SmartNews Ads における機械学習の活用とその運用 #mlops
komiya_atsushi
3
19k
GBDT によるクリック率予測を高速化したい #オレシカナイト vol.4
komiya_atsushi
5
1.3k
Maven central repository の artifact をランキングする #渋谷java
komiya_atsushi
0
1.4k
確率的データ構造を Java で扱いたい! #JJUG
komiya_atsushi
6
2.3k
Other Decks in Programming
See All in Programming
Code as Context 〜 1にコードで 2にリンタ 34がなくて 5にルール? 〜
yodakeisuke
0
130
LT 2025-06-30: プロダクトエンジニアの役割
yamamotok
0
760
初学者でも今すぐできる、Claude Codeの生産性を10倍上げるTips
s4yuba
16
11k
Webの外へ飛び出せ NativePHPが切り拓くPHPの未来
takuyakatsusa
2
550
A full stack side project webapp all in Kotlin (KotlinConf 2025)
dankim
0
120
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
2
800
#QiitaBash MCPのセキュリティ
ryosukedtomita
1
1.3k
20250704_教育事業におけるアジャイルなデータ基盤構築
hanon52_
5
780
Claude Code + Container Use と Cursor で作る ローカル並列開発環境のススメ / ccc local dev
kaelaela
9
5k
RailsGirls IZUMO スポンサーLT
16bitidol
0
180
A2A プロトコルを試してみる
azukiazusa1
2
1.4k
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
470
Featured
See All Featured
Designing Experiences People Love
moore
142
24k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
Testing 201, or: Great Expectations
jmmastey
43
7.6k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
48
2.9k
Thoughts on Productivity
jonyablonski
69
4.7k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
510
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.6k
Optimizing for Happiness
mojombo
379
70k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
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