1. What this solves
When measurements are far apart, the drift and diffusion can change substantially before the next measurement. DynGMA approximates what happens within the gap by composing short Gaussian transition models. Fit the drift and noise by evaluating the resulting mixture at each recorded endpoint.
2. When to use
Use timed pairs in coordinates that plausibly form a time-homogeneous Markov Itô diffusion. Lags may differ across pairs. The drift needs a usable state Jacobian. The likelihood assumes a nonsingular covariance in the modeled coordinates. Start with a low-dimensional state and a few mixture stages. Initial states can be away from equilibrium.
Compare a one-step likelihood and a refined approximation on whole held-out trajectories or independent transitions, using their actual lags. Look for material differences in conditional mean, covariance or density. At matched states and lags, test whether older observations still predict the residuals. Persistent history dependence calls for revisiting the coordinates or observation model.
3. When not to use (and what to use instead)
| Situation | Use instead |
|---|---|
| Only unordered samples are available | Estimate a static density or obtain timed transitions before fitting an evolution law. |
| Matching the observed state still leaves systematic dependence on its history | Identify additional coordinates or fit an observation model. Stochastic OnsagerNet can learn closure when suitable microscopic trajectories are available. |
| A single Euler–Maruyama Gaussian already predicts transitions adequately at the observed lags | Use a one-step likelihood. For an Onsager-structured drift, use Stochastic OnsagerNet. |
| A stationary landscape, irreversible current or EPR is the primary result | Use UIDD for a diffusion with a supported unique invariant density and a specified reversal. |
| Constraints or degenerate noise make the endpoint law singular in these coordinates | Work in suitable reduced coordinates or use a transition model defined on the actual support. |
4. Algorithm
Model a -dimensional column vector by , with independent standard Brownian components in . For example, use an head with outputs and build a square from a trainable strict lower triangle and a diagonal from another head . The likelihood uses the full covariance rate . Paper, Eq. (16)
Evaluate the diagonal in the working precision using
r = 0.5 * hypot(s, 1)andt = 0.5 * s. User + tfor and0.25 / (r - t)for . The reciprocal branch avoids cancellation. Evaluate only the applicable branch for each entry, including under autodiff. Check covariance conditioning separately because a positive diagonal can still be too small for a reliable factorization.For each pair with , choose equal mixture stages of length , for example with . Choose inner steps of length per stage. A stage starting at a point sets and . For , set and let have entries evaluated at . With and , compute and . The stage output is the mean and covariance after the last inner step, and with index . Paper, Eqs. (13)–(14)
Apply one stage to and give the resulting Gaussian weight 1. For each later stage and each parent , factor with lower triangular . Use the point with weight and the points with weight each, for . Here is coordinate vector , so takes a column of . Advance each point by the stage update from zero covariance. Give each output the parent weight times its point weight. Visit parents in order. Within each, the checker expects the center, then positive axes, then negative axes, both in increasing coordinate order. Paper, Algorithm 1
For each final component , factor and solve . Its log contribution is
Let . The endpoint log density is . Minimize the mean of its negative over recorded pairs. Differentiate through the stage updates, Cholesky factors, cubature points and Gaussian terms, holding the observed endpoints and stage counts fixed. Paper, Eq. (17)
5. Parameters
| Parameter | How to choose it |
|---|---|
| and | Try first. Raise when smaller stages improve held-out predictions. With a point start the unpruned mixture contains components. Keep fixed for each pair during differentiation. |
| Check approximation error by refining the inner step while holding fixed. The mean uses a midpoint evaluation even for . | |
| Diffusion factor | Use a full-row-rank factor. The paper builds a triangular factor with a positive diagonal for state-dependent noise. Condition the covariance in the data's working units. |
| Drift parameterization | Fixed known terms can be kept in the drift. Use an analytic Jacobian or autodiff, including its effect on the covariance. |
7. Verification
Step 1. Export affine_mixture, affine_logpdf, benes_logpdf and training_loss_gradient in port_adapter.py. The scalar Beneš test model used by the last two is defined in the checks/cases.json interface: and for weights . Follow the interface in checks/cases.json and run python3 /path/to/dyngma/checks/check_port.py from the directory containing the adapter. Show its output to the user. The fixtures include correlated state-dependent noise, a two-dimensional mixture log density, a surviving tail log density and a fixed two-stage likelihood with two unequal observation lags. The last case checks both weight derivatives. The analytic Brownian moment check exercises the cubature axes and weights.
Step 2. Check the component weights, covariance conditioning and held-out conditional predictions by lag. Inspect the fit at smaller and before trusting estimates of or . For the paper's unit-noise Beneš density comparison, at and the plotted DynGMA density near is about 0.18. The implementation gives 0.176908 with and . This point check is coarse: the exact density there, 0.1894, is also within 0.01 of the plotted value. The paper shows the curves but reports no integrated errors; computed by this reference against the exact transition on , the integrated absolute density errors at that lag are 0.05989 for DynGMA and 0.32182 for the one-step Euler baseline. Figure 2
The separate small fit uses exact transition quantiles from the unit-noise SDE. It compares coefficient recovery and conditional likelihood at unseen starts and lags with a one-step Euler model fitted to the same data. The authors' neural training result in Appendix C was not reproduced. It uses noise amplitude 0.3 and much larger training data. Appendix C, Table 4
8. Failure signatures
| Symptom | Check |
|---|---|
| Correlated directions spread incorrectly while scalar cases pass | Check the columns of the lower Cholesky factor and the and factors. |
| A finite tail log density underflows | Combine normalized Gaussian log terms with log-sum-exp before projecting to density. |
| A component covariance is singular despite full-row-rank noise | Reduce the inner step and check the conditioning of . |
| Likelihood rewards a noise scale close to zero | Inspect rank and conditioning of the data and the fitted covariance. Check whether observed noise, hidden state or deterministic coordinates require a different model. |
| Cost grows quickly on longer intervals | Count stages and cubature branches. Check before increasing the mixture size. |
9. Files and commands
From the method folder run python3 examples/fit_benes.py. The reference kernel and mixture are in reference/dyngma.py. See reference/models.py for the fixed models and loss and reference/benes.py for exact transitions and the toy fit.
Run python3 checks/make_cases.py for the portable fixtures. Run python3 verify/check_cases.py for fixture and derivative checks, python3 verify/check_figure2.py for known-coefficient densities, and python3 verify/check_fit.py for coefficient recovery.
10. Sources
A. Zhu and Q. Li, DynGMA: A robust approach for learning stochastic differential equations from data, Journal of Computational Physics 513, 113200 (2024). See Algorithm 1, Eqs. (13), (14) and (17), Figure 2 and Appendix C. Published paper · Open manuscript · Pinned authors' implementation