Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Oh, you're so random
Search
Vicent Martí
March 25, 2012
Programming
2.7k
14
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Oh, you're so random
Randomness and pink ponies in Codemotion Rome 2012
Vicent Martí
March 25, 2012
More Decks by Vicent Martí
See All by Vicent Martí
Unicorns Die With Bullets Made of Glitter
tanoku
6
640
Threedee Tales From Urban Bohemia
tanoku
3
950
My Mom told me that Git doesn't scale
tanoku
28
2.2k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Ruby is Unlike a Banana
tanoku
97
11k
A talk about libgit2
tanoku
11
1.8k
Other Decks in Programming
See All in Programming
最近”作らせてる” ローカルAIアプリの話
akit37
0
520
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
520
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
310
SODA - FACT BOOK(JP)
sodainc
1
40k
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
130
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
650
ChromeでローカルLLM
ryu1013
0
180
Jetpack Compose Mechanisms
skydoves
3
900
JIS keyboard support in Omarchy
lef237
0
170
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
1.1k
R8 の設定見直しでアプリサイズ削減
andpad
0
240
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
170
Featured
See All Featured
Mind Mapping
helmedeiros
1
420
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
340
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.9k
Designing for humans not robots
tammielis
254
26k
Typedesign – Prime Four
hannesfritz
42
3.2k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
570
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
WENDY [Excerpt]
tessaabrams
14
40k
Site-Speed That Sticks
csswizardry
13
1.6k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
290
How to Talk to Developers About Accessibility
jct
2
600
Transcript
None
select a random element
select a random element ‘tis one is ok.
None
None
Information Theory
hard TOPIC Information Theory
hard TOPIC dumb SPEAKER + Information Theory
0≤H(X)≤1 where X is a discrete random variable
0≤H(X)≤1 where X is a discrete random variable unpredictable
0≤H(X)≤1 where X is a discrete random variable unpredictable always
the same
None
ask a question.
None
bool is_random(char *bytes, size_t n) { }
bool is_random(char *bytes, size_t n) { } AGHHH
UNIFORM distribution
UNIFORM distribution
select a random element array[rand() % array.size]
select a random element array[rand() % array.size] UNIFORM distribution
select a random element array[rand() % array.size] UNIFORM distribution
select a random element array[rand() % array.size] UNIFORM distribution AGHHH
This is how you kill the RANDOM pnrg array
This is how you kill the RANDOM a pnrg array
This is how you kill the RANDOM a pnrg array
This is how you kill the RANDOM a a pnrg
array
This is how you kill the RANDOM a a pnrg
array
This is how you kill the RANDOM a a a
pnrg array
This is how you kill the RANDOM a a a
pnrg array
This is how you kill the RANDOM a a a
pnrg array
This is how you kill the RANDOM a a a
b pnrg array
This is how you kill the RANDOM a a a
b pnrg array
This is how you kill the RANDOM a a a
b b pnrg array
This is how you kill the RANDOM a a a
b b pnrg array
This is how you kill the RANDOM a a a
b b pnrg array
This is how you kill the RANDOM a a a
b b pnrg array
how to FIX:
how to FIX: 1. Random is hard
how to FIX: 1. Random is hard 2. Run away
how to FIX: 1. Random is hard 2. Run away
Math.random() // between 0.0 and 1.0 Javascript
how to FIX: 1. Random is hard 2. Run away
how to FIX: 1. Random is hard 2. Run away
prng.rand(5..9) #=> one of [5, 6, 7, 8, 9] prng.rand(5...9) #=> one of [5, 6, 7, 8] Ruby
Good.
Good. (but I don’t care)
None
“PRNGs and Hash functions are in the same family of
algorithms”
None
hash tables out of nowhere!
hash tables out of nowhere! O(1)
hash tables out of nowhere! O(1) uniform
pathological average data set: O(1)
pathological average data set: O(1)
pathological average data set: O(1) O(n)
ONE fix
ONE fix INT_MAX % size == 0
collide make them
collide make them • Brute force
collide make them • Brute force • MITM
collide make them • Brute force • MITM • Equivalent
substrings
collide make them • Brute force • MITM • Equivalent
substrings
collide make them • Brute force • MITM • Equivalent
substrings
collide make them • Brute force • MITM • Equivalent
substrings
collide make them • Brute force • MITM • Equivalent
substrings
collide make them • Brute force • MITM • Equivalent
substrings
problem & that’s a
problem & that’s a painful comparisons
problem & that’s a painful comparisons ~700ms responses
MANY fixes
MANY fixes (but only one is right)
MANY fixes (but only one is right) 1. Limiting request
size
this is bad and you should feel bad! MANY fixes
(but only one is right) 1. Limiting request size
MANY fixes (but only one is right) 2. Changing the
hash table
MANY fixes (but only one is right) 2. Changing the
hash table (no comment)
MANY fixes (but only one is right) 3. Bring back
the random
None
“Randomness is too important to be left to chance”
Thanks. “Randomness is too important to be left to chance”