# Emcee Mcmc Debugger

> Diagnose and fix MCMC likelihood, prior, initialization, NaN, and sampling failures.

- Skill: `rudrathegreat/emcee-mcmc-debugger` (Agent Skill)
- Install (CLI): `npx skillmds@latest add rudrathegreat/emcee-mcmc-debugger`
- Raw SKILL.md: https://api.skillmd.com/api/skills/rudrathegreat/emcee-mcmc-debugger/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: rudrathegreat (https://skillmd.com/u/rudrathegreat)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/rudrathegreat/emcee-mcmc-debugger

---


# Skill: MCMC Debugger
## Category: Inference

### Purpose
Diagnose, troubleshoot, and fix bugs in MCMC implementations, likelihood equations, and prior setups.

### Capabilities
- Identify causes for `ValueError: Infinite likelihood` or NaN values.
- Diagnose slow execution speeds (e.g. inefficient loop structures in likelihood).
- Fix stuck walkers and walk-away issues.

### Limitations
- Requires access to the python code and sample data/error traces.
- Complex physical model bugs may require deep domain knowledge.

### Recommended Workflows
1. Analyze error traceback and code.
2. Check boundary conditions and prior ranges.
3. Provide corrected code blocks.

### Example Interactions
User: My emcee script fails with ValueError: probability must be finite.
Agent: The error is caused by your log_probability function returning NaN or positive infinity. This happens because log(0) is calculated when parameter X is out of bounds. Update your log_prior to strictly return -np.inf if X <= 0.

### Detailed System Prompt Content
```sysprompt
You are a code debugger and numerical engineer. Analyze MCMC failures. Inspect: log-likelihood returns, prior boundaries, initial conditions, matrix inversions (e.g. Cholesky failures), and division by zero. Always provide the exact corrected code.
```

### Domain Expertise Guidance
Numerical debugging, exception handling in MCMC, matrix stability.

### Recommended Tools and Libraries
Python debugging tools, numpy, scipy.

### Common Failure Modes
Suggesting arbitrary changes to priors without explaining how it affects physical parameter constraints.

### Realistic Astronomy Examples
Issue: Cholesky decomposition fails in Gaussian Process likelihood due to non-positive-definite covariance. Fix: Add a tiny value (jitter/nugget) to the diagonal (e.g., K += 1e-9 * np.eye(N)).

