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.2k
#JJUG Fork/Join フレームワークを効率的に正しく使いたい
komiya_atsushi
0
470
[#JSUG] SmartNews における container friendly な Spring Boot アプリケーション開発
komiya_atsushi
1
11k
Java のデータ圧縮ライブラリを極める #jjug_ccc #ccc_c7
komiya_atsushi
4
4.8k
#devsumi 自然言語処理・機械学習によるファクトチェック業務の支援
komiya_atsushi
1
4.4k
SmartNews Ads における機械学習の活用とその運用 #mlops
komiya_atsushi
3
19k
GBDT によるクリック率予測を高速化したい #オレシカナイト vol.4
komiya_atsushi
5
1.3k
Maven central repository の artifact をランキングする #渋谷java
komiya_atsushi
0
1.3k
確率的データ構造を Java で扱いたい! #JJUG
komiya_atsushi
6
2.2k
Other Decks in Programming
See All in Programming
Multi Step Form, Decentralized Autonomous Organization
pumpkiinbell
1
750
PHPカンファレンス名古屋2025 タスク分解の試行錯誤〜レビュー負荷を下げるために〜
soichi
1
210
お前もAI鬼にならないか?👹Bolt & Cursor & Supabase & Vercelで人間をやめるぞ、ジョジョー!👺
taishiyade
6
4k
動作確認やテストで漏れがちな観点3選
starfish719
6
1k
Formの複雑さに立ち向かう
bmthd
1
860
SwiftUIで単方向アーキテクチャを導入して得られた成果
takuyaosawa
0
270
『テスト書いた方が開発が早いじゃん』を解き明かす #phpcon_nagoya
o0h
PRO
2
290
ML.NETで始める機械学習
ymd65536
0
100
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
48
17k
Unity Android XR入門
sakutama_11
0
160
AIの力でお手軽Chrome拡張機能作り
taiseiue
0
170
もう僕は OpenAPI を書きたくない
sgash708
5
1.8k
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Statistics for Hackers
jakevdp
797
220k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
A Tale of Four Properties
chriscoyier
158
23k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.4k
Into the Great Unknown - MozCon
thekraken
35
1.6k
Practical Orchestrator
shlominoach
186
10k
Producing Creativity
orderedlist
PRO
344
39k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Thoughts on Productivity
jonyablonski
69
4.5k
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