"매 randomness 의 algorithmic resource 사용". Randomized algorithm 은 worst-case input adversary 회피 또는 simpler logic 으로 expected-time 성능 달성. Frontend 에서 quickselect, reservoir sampling, bloom filter, A/B bucketing 등 매 광범위 응용.
매 핵심
매 두 가지 분류
Las Vegas: 매 항상 correct 결과, runtime 만 random (e.g. randomized quicksort).
Monte Carlo: 매 bounded runtime, 결과는 매 probability 1-ε 로 correct (e.g. Miller-Rabin, bloom filter).
매 왜 frontend
매 large dataset (virtualized list, large table) 의 sampling.
매 client-side A/B test bucketing — deterministic hash + random salt.
매 game / animation 의 procedural generation.
매 dedup / membership test (bloom filter) 의 memory 절약.
매 응용
Reservoir sampling — log streaming 의 fixed-size sample.
언제: large dataset 의 sampling/selection, A/B bucketing, client-side dedup, security-irrelevant random.
언제 X: cryptographic context 에 Math.random — 매 절대 X. Token, password, nonce 매 crypto.getRandomValues 만.
❌ 안티패턴
Math.random for security: 매 PRNG 의 predictability — token 에 절대 X.
Naive shuffle (sort(() => Math.random() - 0.5)): 매 non-uniform distribution.
Modulo bias: Math.floor(Math.random() * n) 까지는 OK, 매 crypto byte % n 매 bias 발생 가능.
Repeated bloom filter without size planning: 매 false positive rate 폭증.
🧪 검증 / 중복
Verified (CLRS Ch.5, Mitzenmacher & Upfal "Probability and Computing", MDN Web Crypto).
신뢰도 A.
🕓 Changelog
날짜
변경
2026-05-08
Phase 1
2026-05-10
Manual cleanup — Las Vegas/Monte Carlo 분류, Fisher-Yates/Reservoir/Quickselect/Bloom/AB-bucket 패턴