SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1111.4246 · 2011

The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo

arXiv · PDF · Open in the Atlas

Code that ran

6 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 4 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/1111.4246.json · badge: /api/ran/1111.4246.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
mfouesneau/NUTS reimplementation (classifier label)
classifier basis: classifier_2025
6 ran · 0 no recorded run
JohannesBuchner/PinNUTS extension (classifier label)
classifier basis: classifier_2025
0 ran · 3 no recorded run
FunctionStatusWhere it lives
find_reasonable_epsilon Ran
ran; our contract draft was wrong, not the code
mfouesneau/NUTS/nuts/nuts.py
code served (permissive licence) · get_code("20075d35f2319a01")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

def mock_log_prob_grad(theta):
    """Mock function that returns log probability and gradient"""
    # Simple quadratic log probability: log p(theta) = -0.5 * sum(theta^2)
    logp = -0.5 * np.sum(theta ** 2)
    grad = -theta
    return logp, grad

# Set random seed for reproducibility
np.random.seed(42)

# Create initial parameter position (dimension 4)
theta0 = np.array([0.1, 0.2, -0.1, 0.05], dtype=np.float64)

# Compute initial gradient
logp0, grad0 = mock_log_prob_grad(theta0)

# Define the callable that returns log probability and gradient
f = mock_log_prob_grad

ARGS = {
    "theta0": theta0,
    "grad0": grad0,
    "logp0": logp0,
    "f": f
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
grad_logLikelihood Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
mfouesneau/NUTS/examples/imf_examples.py
code served (permissive licence) · get_code("537a746770a10e4a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned ndarray, ndim 1, dtype family float, shape (1,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Construct arguments for grad_logLikelihood
theta = np.array([0.5])  # alpha parameter, 1D array
D = 2.3  # normalization constant (sum of log masses)
N = 10  # number of data points
M_min = 1.0  # lower limit of mass interval
M_max = 100.0  # upper limit of mass interval

ARGS = {
    "theta": theta,
    "D": D,
    "N": N,
    "M_min": M_min,
    "M_max": M_max,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (1,) — shape (1,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
leapfrog Ran
ran; our contract draft was wrong, not the code
mfouesneau/NUTS/nuts/nuts.py
code served (permissive licence) · get_code("7475a1db9181c908")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

def mock_log_prob_and_grad(theta):
    """Mock function that returns log probability and gradient"""
    # Simple quadratic log probability: -0.5 * sum(theta^2)
    logp = -0.5 * np.sum(theta**2)
    grad = -theta
    return logp, grad

# Set up parameters for leapfrog function
theta = np.array([1.0, 2.0, 3.0, 0.5], dtype=np.float64)
r = np.array([0.1, -0.2, 0.3, -0.1], dtype=np.float64)
logp_initial, grad_initial = mock_log_prob_and_grad(theta)
epsilon = 0.1
f = mock_log_prob_and_grad

ARGS = {
    "theta": theta,
    "r": r,
    "grad": grad_initial,
    "epsilon": epsilon,
    "f": f
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
logLikelihood Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
mfouesneau/NUTS/examples/imf_examples.py
code served (permissive licence) · get_code("18842e42f9d6dd71")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned float64, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Set random seed for reproducibility
np.random.seed(0)

# Define arguments for logLikelihood function
theta = np.array([0.5])  # alpha parameter
D = 2.3  # normalization constant (sum of log masses)
N = 10  # number of data points
M_min = 1.0  # lower mass limit
M_max = 100.0  # upper mass limit

ARGS = {
    "theta": theta,
    "D": D,
    "N": N,
    "M_min": M_min,
    "M_max": M_max
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float64, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
random_PowerLaw Ran
ran, honoured the contract we drafted
mfouesneau/NUTS/examples/imf_examples.py
code served (permissive licence) · get_code("cb1a1453761fca1d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned ndarray, ndim 1, dtype family float, shape (1000,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Set random seed for reproducibility
np.random.seed(42)

# Define arguments for random_PowerLaw function
ARGS = {
    "N": 1000,           # number of samples to draw
    "alpha": 2.5,        # power-law index
    "M_min": 1.0,        # lower bound of mass interval
    "M_max": 100.0,      # upper bound of mass interval
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (1000,) — shape (1000,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
stop_criterion Ran
ran, violated the contract we drafted
mfouesneau/NUTS/nuts/nuts.py
code served (permissive licence) · get_code("e6fec7e2a2392138")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create small 1D numpy arrays for the function parameters
# The function computes dot products and checks conditions on position and momentum vectors

thetaminus = np.array([0.1, 0.2, 0.3, 0.4], dtype=np.float64)
thetaplus = np.array([0.5, 0.6, 0.7, 0.8], dtype=np.float64)
rminus = np.array([0.2, 0.1, 0.3, 0.15], dtype=np.float64)
rplus = np.array([0.25, 0.15, 0.35, 0.2], dtype=np.float64)

ARGS = {
    "thetaminus": thetaminus,
    "thetaplus": thetaplus,
    "rminus": rminus,
    "rplus": rplus,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
build_tree Not yet run
unverified (harvested, no recorded run)
JohannesBuchner/PinNUTS/pinnuts/pinnuts.py
code served (permissive licence) · get_code("4d864798cca4b23b")
How it ran

no invocation recorded.

pinnuts Not yet run
unverified (harvested, no recorded run)
JohannesBuchner/PinNUTS/pinnuts/pinnuts.py
code served (permissive licence) · get_code("4f8a7d049558a7a8")
How it ran

no invocation recorded.

tree_sample Not yet run
unverified (harvested, no recorded run)
JohannesBuchner/PinNUTS/pinnuts/pinnuts.py
code served (permissive licence) · get_code("86a695959d00fddb")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 3 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 3 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
build_tree 1 other paper
1 later
1701.02434 (2017-01)
A Conceptual Introduction to Hamiltonian Monte Carlo
pinnuts 1 other paper
1 later
1701.02434 (2017-01)
A Conceptual Introduction to Hamiltonian Monte Carlo
tree_sample 1 other paper
1 later
1701.02434 (2017-01)
A Conceptual Introduction to Hamiltonian Monte Carlo

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Hamiltonian Monte Carlo (HMC) is a Markov chain Monte Carlo (MCMC) algorithm that avoids the random walk behavior and sensitivity to correlated parameters that plague many MCMC methods by taking a series of steps informed by first-order gradient information. These features allow it to converge to high-dimensional target distributions much more quickly than simpler methods such as random walk Metropolis or Gibbs sampling. However, HMC's performance is highly sensitive to two user-specified parameters: a step size ε and a desired number of steps L. In particular, if L is too small then the algorithm exhibits undesirable random walk behavior, while if L is too large the algorithm wastes computation. We introduce the No-U-Turn Sampler (NUTS), an extension to HMC that eliminates the need to set a number of steps L. NUTS uses a recursive algorithm to build a set of likely candidate points that spans a wide swath of the target distribution, stopping automatically when it starts to double back and retrace its steps. Empirically, NUTS perform at least as efficiently as and sometimes more efficiently than a well tuned standard HMC method, without requiring user intervention or costly tuning runs. We also derive a method for adapting the step size parameter ε on the fly based on primal-dual averaging. NUTS can thus be used with no hand-tuning at all. NUTS is also suitable for applications such as BUGS-style automatic inference engines that require efficient "turnkey" sampling algorithms.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("1111.4246")
get_code_for_paper("1111.4246")
have("1111.4246")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/1111.4246.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/1111.4246.svg)](https://syntology.ai/paper/1111.4246)

Connect an agent — have() is free.