Note
Go to the end to download the full example code.
Multiplicative noise — the Landauer blowtorch¶
A particle hops in a symmetric double well, yet it spends most of its time on the left. The reason is invisible in the force: the bath is hotter on the right — Landauer’s blowtorch. This page recovers the state-dependent diffusion field \(D(x)\) together with the force from a single trajectory, lets PASTIS decide which terms \(D(x)\) needs, and shows that the inferred force and diffusion field together — and only together — predict the lopsided occupancy. The last section repeats the analysis on a recording with localisation noise.
Tags
synthetic · overdamped · multiplicative-noise · 1D
stamp_output()
[Generated: 2026-10-18 18:38]
A double well in a temperature gradient¶
in the Itô convention — the drift in the SDE, and the force SFI
infers, is the Itô drift. The drift is symmetric under
\(x\to -x\); with \(g > 0\) the right well sits in the hot
region. Both fields are built from SFI.bases primitives.
import SFI
from SFI.bases import identity_matrix_basis, unit_axes, x_components
from SFI.langevin import OverdampedProcess
D0 = 0.5 # baseline diffusion
g = 0.3 # temperature gradient
dt = 0.01
(x,) = x_components(1)
(ex,) = unit_axes(1)
I = identity_matrix_basis(1)
F_model = (x - x**3) * ex # F(x) = x - x³ (Itô drift)
D_model = D0 * (1.0 + g * x) * I # D(x) = D₀(1 + g·x)
proc = OverdampedProcess(F=F_model, D=D_model,
theta_F=jnp.array([1.0]), theta_D=jnp.array([1.0]))
proc.initialize(jnp.array([0.5]))
coll = proc.simulate(dt=dt, Nsteps=50_000, key=random.PRNGKey(7),
prerun=200, oversampling=10)
t, X, _mask = coll.to_arrays(dataset=0)
Xarr = np.asarray(X[:, 0, 0])
print(f"{coll.T} frames at dt = {dt}; time spent in the hot half (x > 0): "
f"{np.mean(Xarr > 0):.0%}")
50000 frames at dt = 0.01; time spent in the hot half (x > 0): 35%
Excursions in the hot well are visibly more agitated — and shorter: the occupancy (right) is lopsided although the drift is symmetric.
Infer the force, then the diffusion field¶
The usual linear sequence plus one step:
infer_diffusion_linear()
fits the diffusion field on a matrix-valued polynomial basis
(rank="symmetric_matrix") spanning \(\{1, x, x^2\}\) — wider
than the truth, so the shape of \(D(x)\) is read off the data. The
data are clean, so the "clean" force preset and the WeakNoise
local diffusion estimator apply (unlike the plain mean-squared
displacement, it carries no \(F^2\Delta t\) bias).
from SFI.bases import monomials_up_to
B_force = monomials_up_to(order=3, dim=1, rank="vector")
B_diff = monomials_up_to(order=2, dim=1, rank="symmetric_matrix")
inf = SFI.OverdampedLangevinInference(coll)
inf.compute_diffusion_constant(method="WeakNoise") # constant-D baseline
inf.infer_force_linear(B_force, preset="clean") # Itô drift
inf.compute_force_error()
inf.infer_diffusion_linear(B_diff, M_mode="WeakNoise") # D(x)
inf.compute_diffusion_error()
inf.compare_to_exact(model_exact=proc)
inf.print_report()
D_true = {"1·S00": D0, "x0·S00": D0 * g, "x0^2·S00": 0.0}
for lbl, c, e in zip(B_diff.labels, np.asarray(inf.diffusion_coefficients),
np.asarray(inf.diffusion_coefficients_stderr)):
print(f" D[{lbl:>8}] = {c:+.4f} ± {e:.4f} (true {D_true[lbl]:+.3f})")
--- StochasticForceInference Report ---
Average diffusion tensor:
[[0.45566308]]
Measurement noise tensor:
[[4.6545298e-05]]
Force estimated information: 206.87176513671875
Force: estimated normalized mean squared error (sampling only): 0.00966782719485854
Force Gram condition number: 27.7
Diffusion estimated information: 5631.08984375
Diffusion: estimated normalized mean squared error (sampling only): 0.0002185110366718753
Normalized MSE (force): 0.0271
Normalized MSE (diffusion): 0.0001
Force Coefficient Table
────────────────────────────────────────────────────────────────
# Label Coefficient Std.Err SNR Sig
────────────────────────────────────────────────────────────────
0 1·e0 -8.02124e-03 6.83466e-02 0.1 ·
1 x0·e0 9.80262e-01 1.07872e-01 9.1 *
2 x0^2·e0 -8.47075e-02 6.18883e-02 1.4 ·
3 x0^3·e0 -1.08000e+00 6.60339e-02 16.4 **
────────────────────────────────────────────────────────────────
4/4 basis functions in support, sig: 2* / 1** / 0*** (|SNR| ≥ 2 / 10 / 100)
(Std.err. reflects sampling error only; discretization bias is not included.)
D[ 1·S00] = +0.5042 ± 0.0062 (true +0.500)
D[ x0·S00] = +0.1498 ± 0.0051 (true +0.150)
D[x0^2·S00] = -0.0068 ± 0.0061 (true +0.000)
The diffusion error bars are sandwich estimates from the data alone; they are calibrated here because the basis contains the true \(D(x)\).
Which terms does \(D(x)\) need?¶
sparsify_diffusion()
runs the PASTIS search over subsets of the diffusion basis, exactly as
sparsify_force() does
for the force.
inf.sparsify_diffusion(criterion="PASTIS")
inf.compute_diffusion_error() # covariance of the selected model
for i, c, e in zip(np.asarray(inf.diffusion_support), np.asarray(inf.diffusion_coefficients),
np.asarray(inf.diffusion_coefficients_stderr)):
lbl = B_diff.labels[i]
print(f" selected D[{lbl:>8}] = {c:+.4f} ± {e:.4f} (true {D_true[lbl]:+.3f})")
selected D[ 1·S00] = +0.4994 ± 0.0045 (true +0.500)
selected D[ x0·S00] = +0.1526 ± 0.0044 (true +0.150)
PASTIS keeps the constant and the gradient and drops the quadratic term (right: the information gain saturates at two terms). The constant-\(D\) estimate a standard analysis would report (dash-dot) misses the gradient entirely. (The force band is computed with the average diffusion, so it is somewhat too narrow in the hot well.)
x_grid = np.linspace(-1.9, 1.9, 200)
x_jnp = jnp.array(x_grid[:, None])
F_ci = inf.force_inferred.predict_ci(x_jnp) # mean and pointwise std
D_ci = inf.diffusion_inferred.predict_ci(x_jnp)
F_inf, F_std = np.asarray(F_ci["mean"])[:, 0], np.asarray(F_ci["std"])[:, 0]
D_inf, D_std = np.asarray(D_ci["mean"])[:, 0, 0], np.asarray(D_ci["std"])[:, 0, 0]
D_const = float(np.asarray(inf.diffusion_average).ravel()[0])
F_exact = x_grid - x_grid**3
D_exact = D0 * (1 + g * x_grid)
The blowtorch effect, explained¶
For Itô dynamics the zero-current stationary density is
not the Boltzmann weight of the drift with a constant temperature. Evaluated with the inferred \(\hat F\) and \(\hat D(x)\), it reproduces the empirical histogram; with the constant-\(D\) estimate it predicts two nearly equal wells.
from scipy.integrate import cumulative_trapezoid
def stationary_density(F_vals, D_vals, x_vals):
"""Zero-current Itô stationary density on a grid (normalised)."""
phi = cumulative_trapezoid(F_vals / D_vals, x_vals, initial=0.0)
p = np.exp(phi - phi.max()) / D_vals
return p / np.trapezoid(p, x_vals)
p_exact = stationary_density(F_exact, D_exact, x_grid)
p_inferred = stationary_density(F_inf, D_inf, x_grid)
p_naive = stationary_density(F_inf, np.full_like(x_grid, D_const), x_grid)
With localisation noise¶
Tracked particles come with localisation error. We add Gaussian noise
of standard deviation \(\sigma = 0.1\), as large as a single-frame
displacement \(\sqrt{2D_0\Delta t}\). The linear estimators assume
clean positions; the parametric ones model the noise:
infer_force() profiles
the noise level along with the force, and
infer_diffusion() then
fits \(D(x)\) on the same basis with the force held fixed.
sigma_loc = 0.1
coll_noisy = coll.degrade(noise=sigma_loc, seed=1)
inf_naive = SFI.OverdampedLangevinInference(coll_noisy) # noise-blind
inf_naive.compute_diffusion_constant(method="WeakNoise")
inf_naive.infer_force_linear(B_force, preset="clean")
inf_naive.infer_diffusion_linear(B_diff, M_mode="WeakNoise")
inf_par = SFI.OverdampedLangevinInference(coll_noisy) # noise-aware
inf_par.infer_force(B_force)
inf_par.infer_diffusion(B_diff)
inf_par.sparsify_diffusion(criterion="PASTIS")
inf_par.compute_diffusion_error()
sigma_hat = float(np.sqrt(np.asarray(inf_par.Lambda).ravel()[0]))
print(f"localisation noise: true σ = {sigma_loc}, estimated σ̂ = {sigma_hat:.3f}")
for name, inf_k in [("linear (noise-blind)", inf_naive), ("parametric", inf_par)]:
print(f"{name:>21}: F coeffs {np.round(np.asarray(inf_k.force_coefficients_full), 3)}"
f" D coeffs {np.round(np.asarray(inf_k.diffusion_coefficients), 3)}")
print(f"{'truth':>21}: F coeffs [ 0. 1. 0. -1.] D coeffs [{D0} {D0 * g} 0.]")
for i, c, e in zip(np.asarray(inf_par.diffusion_support), np.asarray(inf_par.diffusion_coefficients),
np.asarray(inf_par.diffusion_coefficients_stderr)):
lbl = B_diff.labels[i]
print(f" parametric, selected D[{lbl:>8}] = {c:+.4f} ± {e:.4f} (true {D_true[lbl]:+.3f})")
localisation noise: true σ = 0.1, estimated σ̂ = 0.101
linear (noise-blind): F coeffs [-0.875 3.378 0.752 -3.454] D coeffs [ 2.012 0.144 -0.009]
parametric: F coeffs [-0.019 0.976 -0.078 -1.133] D coeffs [0.495 0.144]
truth: F coeffs [ 0. 1. 0. -1.] D coeffs [0.5 0.15 0.]
parametric, selected D[ 1·S00] = +0.4950 ± 0.0068 (true +0.500)
parametric, selected D[ x0·S00] = +0.1439 ± 0.0068 (true +0.150)
The noise-blind fit distorts the force several-fold and reads the localisation noise as extra diffusion (its \(\hat D\) is about four times too large). The parametric fit recovers both fields and the noise level itself, and PASTIS selects the same two diffusion terms as on clean data (shaded: \(\pm 2\sigma\) on \(D(x)\)). Two caveats on its error bars: the diffusion ones treat the estimated noise level as known, and since the noise level and \(D_0\) trade off they are somewhat optimistic on noisy data; the force ones assume a constant diffusion and are too narrow in the hot well, which is why no force band is drawn here.
Which “force”? Spurious drifts¶
SFI infers the Itô drift \(F(x) = \lim_{\Delta t\to 0}\langle \Delta x \rangle / \Delta t\). Other conventions move part of the noise gradient into the drift — in 1D, \(F_{\rm Strato} = F_{\rm Itô} - \tfrac12 D'(x)\) and \(F_{\rm anti\text{-}Itô} = F_{\rm Itô} - D'(x)\). Which one is the physical force is an experimental question; once \(F_{\rm Itô}\) and \(D(x)\) are both inferred, the conversion is immediate:
dD = np.gradient(D_inf, x_grid) # D'(x) of the inferred field
F_strato = F_inf - 0.5 * dD
F_anti_ito = F_inf - dD
print(f"inferred D'(x) = {dD.mean():.3f} (true {D0 * g})")
inferred D'(x) = 0.153 (true 0.15)
Here \(D'\) is constant, so the conventions differ by a uniform shift of the drift — enough to move its zeros, the apparent well bottoms. Note that the density formula above peaks where \(F_{\rm Itô} = D'\): at the zeros of the anti-Itô drift, which is why the occupancy peaks sit slightly left of \(\pm 1\).
Thumbnail¶
Dedicated single-panel figure for the gallery thumbnail.
Total running time of the script: (1 minutes 5.821 seconds)