TL;DR
Large Language Models (LLMs) deployed as autonomous agents struggle with a fundamental requirement: generating truly random, unbiased choices from a specified distribution. While their outputs appear random due to token-generation entropy, this "illusion of stochasticity" is heavily warped by training data and positional biases, making agentic policies highly predictable and exploitable. Crucially, the paper demonstrates that while LLMs fail at native random number generation, they excel at deterministically converting an externally provided random seed into complex target distributions.
What Problem Does This Paper Address?
As LLMs transition from passive chatbots to active agents interacting with environments—such as playing games, optimizing security patrols, or running reinforcement learning loops—they frequently need to execute stochastic policies. For instance, a game-playing agent shouldn't always make the exact same opening move, and a multiple-choice question generator should randomize where the correct answer lands to prevent predictability.
However, there is a distinct "knowing-doing gap" in current models. Even when an LLM explicitly states and understands a target probability distribution in its reasoning trace, its final token output fails to reflect that distribution. Because LLMs are designed to sample tokens from a vocabulary based on textual probability rather than actions from a semantic action space, their native sampling is fundamentally flawed. This paper systematically exposes this vulnerability, showing how it leaves agentic systems open to adversarial exploitation.
Methods
The authors evaluate several state-of-the-art model families (including Gemini-2.5/3.0, Qwen3, and OLMo-3) across various sampling paradigms:
- Direct Prompting (Independent Sampling): Asking the model to directly sample from uniform discrete, uniform continuous, or Gaussian distributions.
- Decoding Parameter Ablation: Testing if adjusting temperature ($T$), top-p, or top-k can restore uniform or Gaussian properties.
- Sequential & Batched Sampling: Providing the model with its own generation history (all-history or last-history) or asking it to generate a large batch (e.g., 1024 samples) at once to see if context improves randomness.
- PRNG Simulation and Tool-Use: Enabling the model to write and execute Python code using a pseudo-random number generator (PRNG), or emulating a PRNG algorithm step-by-step via Chain-of-Thought (CoT).
- Distribution Conversion: Providing a true random number $U[0,1]$ directly in the prompt and asking the LLM to deterministically map it to a target distribution (e.g., via inverse transform sampling or bucketization).
Statistical rigor is maintained using Goodness-of-Fit (GoF) tests, specifically Chi-Square tests for discrete distributions and Kolmogorov-Smirnov tests for continuous ones.
Datasets
The paper does not rely on standard pre-existing datasets. Instead, the authors evaluate the models using custom synthetic generation tasks designed to test specific statistical properties. These include:
- Randomizing multiple-choice options (A, B, C, D).
- A simulated Stackelberg security game (choosing one of four servers to protect uniformly).
- Sampling tasks across sets of integers (0-9, 1-100), colors, letters, directions, and continuous ranges ($[0,1]$, $[-1,1]$).
Key Insights and Ideas
- The "C" Bias and Exploitation: When asked to generate multiple-choice questions, LLMs exhibit a massive bias toward making "C" the correct answer. In adversarial settings like security games, this predictable behavior allows an adaptive attacker to achieve a near-100% success rate against an LLM agent that knows it should be acting uniformly.
- Post-Training Amplifies Bias: Interestingly, base (pre-trained) models are much closer to uniform token distributions than their instruction-tuned or reasoning counterparts. Alignment processes like RLHF seem to severely distort the model's internal logit distributions, amplifying the illusion of stochasticity.
- Positional and Cultural Biases: Models prefer specific numbers (like 7 or 42) due to their high presence in training data, or change their distribution entirely based on the order of elements listed in the prompt.
- The Core Failure is Generation, Not Math: LLMs fail at generating randomness, but they are excellent at transforming it. When given a true random number $U[0,1]$ in the prompt, frontier models can execute deterministic algorithms (like bucketization or inverse transform sampling) to perfectly match complex target distributions, including Gaussian Mixture Models.
Key Results
- Goodness-of-Fit Failures: Across all direct prompting tests for uniform and Gaussian distributions, GoF tests yielded p-values of practically zero (e.g., $< 10^{-300}$), completely rejecting the hypothesis that LLMs can sample reliably on their own. Scaling up model size (e.g., from Qwen3-8B to 32B) did not fix this.
- Decoding Tweaks Fail: Raising the temperature makes the empirical distribution look slightly closer to the target, but even at extreme temperatures ($T=2.0$), p-values remain significantly below the 0.05 significance threshold, and parsing errors skyrocket.
- Sequential Repulsion: Sequential sampling with history introduces severe temporal biases. Instead of treating each draw independently, models exhibit a "repulsive" bias, actively avoiding the number they just generated.
- Successful Conversion: When provided an external random seed in $[0,1]$, larger models (Qwen3 $\ge$ 4B, Gemini Pro) achieved successful distribution conversions with p-values well above 0.05 (e.g., 0.78 for Qwen3-32B on Gaussian conversion), proving their algorithmic execution is sound.
Limitations and Future Work
- Computational Cost: Simulating PRNGs via Chain-of-Thought or spinning up a Python sandbox for every single action is computationally prohibitive and slow for real-time agentic deployments.
- State Tracking: PRNGs are stateful, whereas standard LLM APIs are stateless. Forcing an LLM to track its seed state across independent inference calls is highly fragile and prone to failure if multiple calls happen concurrently.
- Proposed Solution: The authors suggest that a pragmatic fix is providing LLM agents with access to an external, stateful sampler tool rather than relying on native token generation.
- Future Directions: Promising areas of future work include exploring whether specialized post-training objectives (like distribution matching) or architectural modifications (like Fourier heads) can natively teach Transformers true randomness without degrading their core capabilities.
Summary updated