agentleFS
90184479018447/julia-pro-p/skills/equation-discovery/SKILL.md

equation-discovery

Skill0 starsChanged 4 days agoMITView on GitHub

Discover governing equations from data with DataDrivenDiffEq.jl: library construction, sparse regression, thresholding, and checks on held-out trajectories. Use when the model form is unknown.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    After training a Universal Differential Equation (UDE), use SINDy on the trained neural network to extract symbolic equations -- the …

    line 55
  2. Very specific:

    When the coefficients need credible intervals or an inclusion probability per library term, the Turing horseshoe route wraps a …

    line 64

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Equation Discovery

Discover governing equations directly from trajectory data using sparse regression (SINDy) and symbolic regression.

SINDy Overview

SINDy (Sparse Identification of Nonlinear Dynamics) recovers governing equations from data:

dX/dt = Theta(X) * Xi
  • X: State matrix (n_samples x n_states)
  • dX/dt: Time derivative matrix (measured or numerically estimated)
  • Theta(X): Library matrix of candidate nonlinear functions (polynomials, trig, etc.)
  • Xi: Sparse coefficient matrix — nonzero entries reveal the active terms

The key insight: most dynamical systems have sparse representations in a suitable function basis. Sparsity-promoting regression recovers the few active terms.

Thresholding Strategies

AlgorithmBest ForKey ParameterNotes
STLSQClean data, default choicethreshold (0.01-0.3)Sequential thresholded least squares; fast, interpretable
SR3Noisy data, relaxed sparsitythreshold, relaxationSparse relaxed regularized regression; more robust to noise
ADMMConstrained problemsthreshold, rhoAlternating direction method of multipliers; enforces constraints

Full solver calls for each algorithm are in references/julia-datadriven-diffeq.md.

Validation Strategies

  1. Cross-prediction on held-out data: Split trajectories into train/test; fit on train, predict on test
  2. Pareto front sweep: Vary the sparsity threshold and plot model complexity vs prediction error
  3. Multi-trajectory validation: Fit on one trajectory, validate on independent initial conditions
  4. Long-time stability: Simulate discovered equations well beyond the training time horizon

Rule: Always validate on held-out data not used in the SINDy fit. In-sample error is misleading for sparse models. The threshold-sweep script lives in references/julia-datadriven-diffeq.md.

Handling Noisy Data

Noise LevelStrategyDetails
Clean (SNR > 100)Direct STLSQUse raw derivatives; threshold=0.05-0.1
Moderate (SNR 10-100)Smoothed derivatives + SR3Apply Savitzky-Golay or total variation smoothing before SINDy; use SR3 for robustness
High (SNR < 10)Integral SINDy or ensembleUse weak-form / integral formulation to avoid derivative estimation; ensemble averaging over subsampled data

Rule: Never use finite differences on noisy data. Use smoothed or integral formulations.

Connection to UDE

After training a Universal Differential Equation (UDE), use SINDy on the trained neural network to extract symbolic equations -- the UDE+SINDy pipeline:

  1. Train the UDE with a neural closure, as in bayesian-ude-workflow
  2. Generate synthetic data from the trained UDE
  3. Apply SINDy to the neural network output to recover interpretable equations
  4. Validate the symbolic model against the original data

Bayesian SINDy

When the coefficients need credible intervals or an inclusion probability per library term, the Turing horseshoe route wraps a DataDrivenDiffEq library in a Turing.@model.

Depth

PageOpen when
julia-datadriven-diffeqbasis construction, the three solver calls, implicit SINDy, the discover-simulate-validate loop, the threshold sweep
symbolic-regressionthe basis is too small and SymbolicRegression.jl should search for the expression

Traps

PitfallSymptomFix
Library too smallHigh residual, poor fitAdd domain-specific terms (trig, exp, cross terms)
Library too largeOverfitting, spurious termsIncrease sparsity threshold; use information criteria (AIC/BIC)
Noisy derivativesUnstable coefficients across thresholdsSmooth data or use integral SINDy formulation
Insufficient dataUnderdetermined systemCollect longer trajectories or multiple initial conditions
Wrong coordinate systemComplex equations with many termsTransform to physically meaningful coordinates before SINDy
Threshold too aggressiveMissing true dynamics termsSweep thresholds and inspect Pareto front for elbow

Done when

The derivative estimate matches the noise level of the data (finite differences on clean data, smoothed or integral formulations on noisy data), the candidate library holds the basis functions the physics admits, and the sparsity threshold was chosen at the elbow of the complexity-versus-error Pareto front rather than by convention. The discovered equations reproduce held-out trajectories and stay bounded well past the training horizon; comparing STLSQ, SR3, and ADMM shows the same terms surviving.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.