Efficient Weighted Sampling // A Random Walk Through Geek-Space
Here’s a really simple and cheap way to do importance sampling that I came across a few months ago (while learning about particle filters, incicentally). It’s simple enough that I have no idea how I went so long without ever knowing about it! In case anyone else is in the same boat - let me walk you through it. Let’s say you have an array of N values, and an associated array of N weights and you want to randomly sample your input values such that the probability of each value being chosen is proportional to its weight. There are many ways of doing that, but I’d like to focus on a particularly efficient approach (it’s O(N) with a relatively small constant factor). Imagine laying out 8 input values in a row like this, where their weights correspond to their width in the diagram. Now, to select 8 weighted samples we could line up another row of evenly spaced “cells” below the first one, corresponding to our chosen samples (modulo my poor mspaint skills). To pick our samples, we could just
Efficient Weighted Sampling // A Random Walk Through Geek-Space A Random Walk Through Geek-Space Brain dumps and other ramblings from Sebastian Sylvan Efficient Weighted Sampling 28 / Jan 2017 Here's a really simple and cheap way to do importance sampling that I came across a few months ago (while learning about particle filters , incicentally). It's simple enough that I have no idea how I went so long without ever knowing about it! In case anyone else is in the same boat - let me walk you through it. Let's say you have an array of N values, and an associated array of N weights and you want to
saved by
related reading
- Sampling: Two Basic Algorithmsgregorygundersen.com
- Importance Sampling Explained | Built Inbuiltin.com
- A Simplified Overview of Langevin Dynamicsfriedmanroy.github.io
- abseil / Performance Hintsabseil.io
- A Gallery of Methods Beyond RL — Part I: Sampling Methodsshengyu-feng.github.io
- Competing with sampling — Alignment Research Centeralignment.org
- Importance Samplingpbr-book.org
- [2605.05179] Estimating the expected output of wide random MLPs more efficiently than samplingarxiv.org
- Why Momentum Really Worksdistill.pub
- Learning the integral of a diffusion model – Sander Dielemansander.ai
- The power of selectiontsvibt.blogspot.com
- Your Transformer is Secretly an EOT Solver | Elements of a Vector Spaceelonlit.com