Thompson sampling is a probabilistic decision heuristic for balancing exploration and exploitation in multi-armed bandit problems. It chooses actions according to sampled beliefs about expected reward, allowing the system to learn while still pursuing high-value options.