Home/Algo Bridge/Reservoir Sampling & Probability Simulation/LC_382
⚡ Practice in Flashcards
🌉 Problem-Level AI BridgeLC_382 · 中等

LC_382 (Linked List Random Node) ➔ Weighted Sampling via Inverse CDF

Reservoir sampling selects items from an unbounded stream with uniform probability k/(i+1) in a single pass.

1️⃣ 1️⃣ Classical DSA Origin

LC_382 · Linked List Random Node

Pattern: Reservoir Sampling & Probability Simulation — Reservoir Sampling. Replaces items in a buffer of size k with dynamically decaying probability k/(i+1) as item i arrives, provably guaranteeing every stream element has identical k/N inclusion probability without knowing total stream length.

⚡ Open LC-382 Solution ➔
2️⃣ 2️⃣ Production AI System Transfer

Streaming Reservoir Sampling for Web-scale Datasets · Weighted Sampling via Inverse CDF

Industrial Application: Streams gigabytes of web crawl data into pretraining training batches with provably uniform distribution without caching entire datasets.

🧬 Target AI Kernel Interface
def sample_inverse_cdf(weights: list[float], num_samples: int = 1) -> list[int]
← LC_136 (Single Number) → Low-bit Quantization (INT4 / NF4) & Bit Unpacking KernelsLC_48 (Rotate Image) → FlashAttention & Online Softmax SRAM Tiled Acceleration →