Skip to main content

kramers

Escape and first-passage results you can run and check.

kramers is an open handbook of first-passage and escape results in statistical physics. Every result is a Python function, tied to the paper and equation that print it, and checked against an independent solver every time the code changes.

import kramers
from kramers.formulas import passage_time_saddle_node, kramers_rate_overdamped

kramers.search("resetting")            # find results
e = kramers.get("K0004")               # one entry: its sources, validity and checks
print(e.cite())                        # what to cite: the original paper first
e.verify()                             # run its checks yourself

Sixty seconds

$ python examples/quickstart.py

It recomputes, in a few seconds, numbers printed in four papers (a neuron's firing rate at threshold, the Airy-function passage time through a noisy saddle-node, the optimal resetting rate, the Sparre Andersen survival law) and shows how far Kramers' formula is from the exact escape rate at 5, 10 and 20 kT.

What is inside

  • The handbook. One entry per published result: the function, the source that prints it (with the equation number, the page and the version that was read), where it holds, and the checks it passes. Thirty entries today, in seven areas: escape over a barrier, switching under a ramp, diffusion to a target, stochastic resetting, active and anomalous motion, transport in periodic potentials, neuron models.
  • Reference solvers, the independent computations the checks rest on:
    • first-passage moments, splitting probabilities and decay rates of one-dimensional diffusions, by quadrature in logarithms, at any barrier height (rates down to 1e-300), including drifts that reach infinity in finite time (limits below);
    • the time-dependent Fokker-Planck equation, for distributions and for ramped (time-dependent) drifts;
    • simulation with boundary-crossing correction and resetting;
    • numerical Laplace inversion.
  • Validity maps. For approximate results, the error against the exact answer across the parameter range: Kramers' rate, for example, is 3% to 6% too high at a 10 kT barrier, depending on the shape of the well.
  • Questions for authors. Implementing and checking a printed equation sometimes finds a disagreement. Each is listed with the computation, as a question to the authors until they answer, in docs/errata.md.

Known limits of the solvers

  • The quadrature solver finds the shape of the potential (and of D, when D varies) by sampling it. A well or barrier narrower than about 1/8000 of the domain can be missed, and then its error estimate misses it too: give such features as breakpoints.
  • An infinite end is cut where its weight is negligible, and the region beyond is scanned out to 1e8 times the cut's distance. A natural end is moved outwards past any rebound the scan finds; an exit end with structure beyond the cut is refused. A feature narrower than about 0.1% of its distance from the cut can escape the scan. Ends that are reached in finite time ("exit") need a constant D.
  • Decay rates are returned with a bracket built from error intervals on the coefficients of the characteristic function: about 1e-13 wide normally, about 1e-6 when the two slowest rates nearly coincide (two equal wells far apart). The intervals are estimates (two discretisations and a rounding floor), not interval arithmetic.
  • A D that vanishes, or a potential that is singular, inside the domain is refused when the panels cannot resolve it; this is found by sampling, so it is not a proof that D is positive everywhere.
  • The Fokker-Planck solver does not keep the density positive at large early time steps, and its Richardson extrapolation can give survival slightly above one when the coarse grid is under-resolved; info["richardson_change"] reports the correction.

These are tested in tests/ with the inputs that first exposed them.

The entries

Entry Result Kind Primary source
K0001 Kramers' escape rate, overdamped (Smoluchowski) limit asymptotic P. Haenggi, P. Talkner and M. Borkovec, Rev. Mod. Phys. 62, 251 (1990)
K0002 Exact mean first-passage time in one dimension (quadrature formula) exact P. Haenggi, P. Talkner and M. Borkovec, Rev. Mod. Phys. 62, 251 (1990)
K0004 Mean passage time through a noisy saddle-node, closed form in Airy functions exact D. Hathcock and J. P. Sethna, Phys. Rev. Research 3, 013156 (2021)
K0005 Noisy saddle-node exactly at the bifurcation: mean, variance and CV of the passage time exact B. Lindner, A. Longtin and A. Bulsara, Neural Comput. 15, 1761 (2003)
K0006 Escape rate near a saddle-node, weak noise (Kramers limit) asymptotic B. Lindner, A. Longtin and A. Bulsara, Neural Comput. 15, 1761 (2003)
K0008 Decay rate of the noisy fold at any barrier height (computed reference) computed-reference computed here
K0024 Distribution of the switching point under a ramp (quasi-static approximation) exact O. K. Dudko, G. Hummer and A. Szabo, Phys. Rev. Lett. 96, 108101 (2006)
K0025 Escape rates from a switching histogram (Fulton-Dunkleberger transformation) estimator J. N. Kaemmerer, S. Masis, K. Hambardzumyan, P. Lenhard, U. Strobel, J. Lisenfeld, H. Rotzinger, A. V. Ustinov et al., arXiv:2411.15048 (2024)
K0026 Force-dependent escape rate of Dudko, Hummer and Szabo asymptotic O. K. Dudko, G. Hummer and A. Szabo, Phys. Rev. Lett. 96, 108101 (2006)
K0027 Mean and variance of the rupture force under constant loading (Dudko, Hummer and Szabo) asymptotic O. K. Dudko, G. Hummer and A. Szabo, Phys. Rev. Lett. 96, 108101 (2006)
K0028 Force-dependent lifetimes from rupture-force histograms (Dudko, Hummer and Szabo, 2008) estimator O. K. Dudko, G. Hummer and A. Szabo, Proc. Natl. Acad. Sci. USA 105, 15755 (2008)
K0029 Most probable rupture force under constant loading (Bell-Evans) exact Z. Liu, H. Liu, A. M. Vera, R. C. Bernardi, P. Tinnefeld and M. A. Nash, Nat. Commun. 11, 4321 (2020)
K0030 Switching of the noisy fold under a linear ramp, without the quasi-static approximation (computed reference) computed-reference computed here
K0003 Splitting probability between two absorbing ends in one dimension exact L. Dagdug and A. M. Berezhkovskii, J. Chem. Phys. 131, 056101 (2009)
K0012 Drift-diffusion on an interval: exit probability, mean and conditional exit times exact S. Redner, Physica A 631, 128545 (2023)
K0013 First-passage duality: conditional exit times do not depend on the sign of the drift exact P. L. Krapivsky and S. Redner, J. Stat. Mech. (2018) 093208
K0014 Exit time of Brownian motion from a ball in d dimensions: mean and second moment exact H. Chen and F. Huang, Phys. Rev. E 105, 034109 (2022)
K0015 Diffusion with stochastic resetting: mean time to reach the target exact M. R. Evans and S. N. Majumdar, Phys. Rev. Lett. 106, 160601 (2011)
K0016 Optimal resetting rate for diffusion to a target exact M. R. Evans and S. N. Majumdar, Phys. Rev. Lett. 106, 160601 (2011)
K0017 Any first-passage process under Poissonian restart: mean and second moment exact S. Reuveni, Phys. Rev. Lett. 116, 170601 (2016)
K0018 Restart helps at small rates exactly when the coefficient of variation exceeds one exact A. Pal and S. Reuveni, Phys. Rev. Lett. 118, 030603 (2017)
K0019 Mean completion time under sharp (periodic) restart exact A. Pal, A. Kundu and M. R. Evans, J. Phys. A 49, 225001 (2016)
K0020 Sparre Andersen theorem: universal survival probability of a symmetric random walk exact A. J. Bray, S. N. Majumdar and G. Schehr, Adv. Phys. 62, 225 (2013)
K0023 Mean exit time of a run-and-tumble particle from an interval exact L. Angelani, R. Di Leonardo and M. Paoluzzi, Eur. Phys. J. E 37, 59 (2014)
K0021 Mean velocity in a tilted periodic potential (Stratonovich's formula) exact P. Reimann, C. Van den Broeck, H. Linke, P. Haenggi, J. M. Rubi and A. Perez-Madrid, Phys. Rev. Lett. 87, 010602 (2001)
K0022 Effective diffusion in a tilted periodic potential exact P. Reimann, C. Van den Broeck, H. Linke, P. Haenggi, J. M. Rubi and A. Perez-Madrid, Phys. Rev. Lett. 87, 010602 (2001)
K0007 Rate near a saddle-node to first order in the bias asymptotic B. Lindner, A. Longtin and A. Bulsara, Neural Comput. 15, 1761 (2003)
K0009 Firing rate of the quadratic integrate-and-fire neuron with white noise exact N. Brunel and P. E. Latham, Neural Comput. 15, 2281 (2003)
K0010 Firing rate of the leaky integrate-and-fire neuron with white noise (Siegert formula) exact N. Brunel, J. Comput. Neurosci. 8, 183 (2000)
K0011 Variance of the passage time through a noisy saddle-node, any bias and thresholds exact B. Lindner, A. Longtin and A. Bulsara, Neural Comput. 15, 1761 (2003)

Other open tools for first passage and escape, each worth using for what it does best. kramers' own contribution is a sourced, independently checked collection of results; where these tools overlap with an entry, the entry's page says so.

  • stochkin: mean first-passage times, exit times and committors from one- and two-dimensional free-energy surfaces (reads PLUMED output).
  • PyFPT: first-passage-time distributions by importance sampling, built for stochastic inflation (Jackson, Harry and Krawczyk, JOSS 2023).
  • deeptime: Markov-state models and transfer operators; its prinz_potential example is an overdamped one-dimensional diffusion like those here.
  • fplanck: a Fokker-Planck solver.
  • py-pde: partial differential equations, including Fokker-Planck problems.
  • kramersmoyal: Kramers-Moyal coefficients estimated from data (Rydin Gorjão and Meirinhos, JOSS 2019).
  • stochrare: rare events in stochastic dynamics (Herbert), including the escape law behind the ramp entries.
  • PyEscape: narrow-escape simulations (Hughes, Morris and Tomkins, JOSS 2020).
  • ForceSpectroscopyMLE: maximum-likelihood fits of force-spectroscopy models, including Dudko-Hummer-Szabo (Julia).

Take part

You have You can
Ten minutes and a paper of your own in the handbook Check its entry: is the equation, the range of validity, the citation right?
An hour Add an entry from the open list; the paper, the equation and the check are named
An experiment Propose a case: one published measurement, recomputed
A course Use entries as self-checking exercises

How, and how credit works: CONTRIBUTING.md. Everyone who contributes is named on the release. The original paper is always cited first.

How it is made

kramers is developed with AI-assisted tools; every number reruns. Nothing here asks to be trusted: every equation's source was opened and its location recorded, and no entry is accepted unless an independent numerical check passes. Details, and what we will and will not do: HOW_THIS_IS_MADE.md.

Status

Version 0.1.0, the first public version (25 October 2026). The verification report of the latest full run is in reports/verification.md. Nothing here is new physics: each page gives the history of its result.

Install

pip install kramers         # NumPy and SciPy are the only dependencies

From a clone, with the checks:

pip install -e ".[dev]"
python -m pytest            # the fast checks
python tools/verify_all.py --slow   # everything, including simulations

MIT licence.

Metadata

Release files for kramers 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kramers 0.1.0
File Size Uploaded Provenance Actions
kramers-0.1.0.tar.gz 99.3 kB With provenance Details for kramers-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kramers 0.1.0
File Interpreter ABI Platform Actions
kramers-0.1.0-py3-none-any.whl Python 3 none any Details for kramers-0.1.0-py3-none-any.whl

Total release size: 219.3 kB

Release files / kramers-0.1.0.tar.gz

Download URL kramers-0.1.0.tar.gz
Size 99.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7bb24bd16422871038ee788f59ccda86b493ecb53b8fc975323f3845969a3175
BLAKE2b-256 checksum
How to use checksums
7c79cd2b08358e6370e4d438268648c05fb5b088ba93c613b144e1b32c5f563c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / kramers-0.1.0-py3-none-any.whl

Download URL kramers-0.1.0-py3-none-any.whl
Size 120.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
212ca865273a0cb350285b5c2101e2a314bf098af7c04a4663ec821486de18b4
BLAKE2b-256 checksum
How to use checksums
354e639e7d75ae4fbb71f7114a280b6314a7a66dc815754d076c22c53fefbaaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for kramers 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kramers-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page