agentleFS
90184479018447/julia-pro-p/skills/bayesian-inference/SKILL.md

bayesian-inference

Skill0 starsChanged 2 days agoMITView on GitHub

Bayesian inference in Julia: Turing.jl model design, priors and reparameterisation, MCMC diagnostics, consensus sampling, and variational approximations. Use when a posterior is the deliverable.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are 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.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write the generative story in words: before the code: what is observed, what is latent, what the prior says about each.

    line 19

≈ “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

Bayesian inference

The model is a generative story; the sampler is a diagnostic problem. Most "the sampler is broken" cases are a model that is not identified, or a prior that fights the data.

TaskPage
design a Turing.jl model, choose priors, reparameteriseturing-model-design
read the diagnostics: R-hat, ESS, divergences, tree depthmcmc-diagnostics
when and how to use variational inference insteadvariational-inference-patterns
multi-modal posteriors, parallel tempering, consensusconsensus-mcmc-pigeons

The working order

  1. Write the generative story in words before the code: what is observed, what is latent, what the prior says about each.
  2. Simulate from the prior. Draw parameters, generate data, refit. If the fit does not recover the truth, the model or the prior is wrong, and no sampler will fix it.
  3. Non-centred parameterisation for hierarchical scales. A centred scale parameter and few groups is the classic funnel that produces divergences.
  4. Sample with four chains, more than you think. Then read R-hat, ESS, divergence count, and tree depth together.
  5. Posterior predictive check. Simulated data from the posterior must look like the data you have, on the statistic you care about.

Diagnostics that mean something

  • Divergences present → the geometry is bad (funnel, unidentifiable pair), not a tuning problem. Increase adapt_delta only to confirm it is geometry.
  • R-hat > 1.01 → chains disagree; often a multi-modal posterior or a chain stuck in a region.
  • Low ESS with high R-hat fix → autocorrelation; thin nothing, sample longer.
  • Tree depth at the maximum → the sampler is hitting the limit every iteration; reparameterise.
  • Prior and posterior nearly identical → the data say nothing; that is a result, report it.

Traps

  • Uniform prior on a scale. It pushes mass to large values; use a half-normal or half-Cauchy with a stated scale.
  • Comparing models by marginal likelihood without checking the sampler. Bridge sampling and WAIC disagree for a reason; look at the posterior predictive first.
  • Variational inference for a decision. VI underestimates posterior variance; use it for exploration, not for an interval you will publish.
  • Ignoring the warm-up. Draws before adaptation are not from the posterior.

Done when

The prior for every scale parameter has a stated scale and a justification (a half-normal on a physical bound, not a flat line to infinity), the sampler was checked on a problem with a known posterior before the real one, every reported interval carries R-hat, ESS, and divergences, and the posterior predictive was compared against held-out data rather than against the training set.

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.