algorithms
3 posts
- Quant interview toolkit · sampling algorithms
How to keep one uniformly random trade from a stream
Derive the replacement rule for an unknown stream length, prove the joint law for a sample of k, and see how a stopping rule can bias the result.
- Quant interview toolkit · numerical statistics
A one-pass variance you can merge across machines
Derive Welford's update from a moving mean, merge two shard summaries by hand, and diagnose a zero variance caused by floating-point cancellation.
- Quant interview toolkit · weighted sampling
Draw trades by size without drawing the same trade twice
Use exponential clocks to sample weighted records in one pass. A three-trade example shows why the first-draw probability differs from final inclusion probability.