simulation
Design Monte Carlo simulations for theoretical validation: sample size determination, convergence diagnostics, and result presentation. Specialized for statistical methodology papers.
What this skill does
# Monte Carlo Simulation Design
Help the researcher design rigorous Monte Carlo simulations to validate theoretical results. Simulations bridge the gap between theory and practice -- they demonstrate that analytical formulas work as predicted and reveal finite-sample behavior.
## Step 1: Read Context
Read `.papermill/state.md` (Read tool) for:
- **Thesis**: What theoretical result needs validation.
- **Experiments**: Any existing simulation experiments.
If `.papermill/state.md` does not exist, ask the user which theoretical result needs validation. Simulation design can proceed without the state file — suggest running `/papermill:init` afterward.
Scan the repository for existing simulation code and results (Glob/Read tools).
## Step 2: Identify What to Validate
Ask: "Which theoretical result are you validating with this simulation?"
Common simulation targets in methodology papers:
- **Asymptotic distributions**: Does the CLT approximation hold at finite n?
- **Estimator properties**: Is the MLE unbiased? What is its MSE?
- **Covariance/information matrices**: Does the empirical covariance match the theoretical Fisher information?
- **Confidence interval coverage**: Do 95% CIs actually cover 95% of the time?
- **Power analysis**: Can the test detect a given effect size?
- **Algorithm convergence**: Does the optimizer find the right answer?
## Step 3: Design the Simulation
### Parameters
- **True parameter values**: Choose several configurations spanning easy, moderate, and hard cases.
- **Sample sizes**: Include small (n=20-50), moderate (n=100-500), and large (n=1000+) to show convergence.
- **Number of replications**: Typically R=1,000-10,000. More replications reduce Monte Carlo error but cost time. The Monte Carlo standard error for a proportion p is sqrt(p(1-p)/R).
### Data Generation
Specify exactly how to generate synthetic data:
1. Set random seed for reproducibility.
2. Generate from the known model with known true parameters.
3. Apply the estimation/inference procedure to each replicate.
4. Collect the quantities of interest.
### Metrics
| What to measure | How to summarize |
|----------------|-----------------|
| Bias | Mean(estimate) - true value |
| Variance | Var(estimates) across replicates |
| MSE | Bias^2 + Variance |
| Coverage | Fraction of CIs containing true value |
| Convergence rate | Plot metric vs. n on log scale |
### Memory and Compute
- **Batch processing**: If R * n is large, process in batches to control memory. Accumulate sufficient statistics rather than storing all raw data.
- **Parallelization**: Independent replicates are embarrassingly parallel. Use `parallel` (R), `multiprocessing` (Python), or OpenMP (C++).
- **Progress reporting**: For long simulations, report progress every ~10% of replicates.
## Step 4: Convergence Diagnostics
Before presenting results, verify the simulation itself is reliable:
1. **Monte Carlo standard errors**: Report them alongside point estimates. If MCSE is large relative to the quantity of interest, increase R.
2. **Trace plots**: Plot running averages to verify convergence.
3. **Sensitivity to seed**: Run with 2-3 different seeds. Results should be stable.
## Step 5: Result Presentation
Design the output tables and figures:
### Tables
- Rows: parameter configurations or sample sizes
- Columns: bias, SD, MSE, coverage, or whatever metrics are relevant
- Include Monte Carlo standard errors in parentheses
### Figures
- **Convergence plots**: Metric vs. n (log scale) with theoretical prediction overlaid
- **QQ plots**: Compare empirical distribution of estimator to theoretical asymptotic distribution
- **Box plots**: Distribution of estimates across replicates for each configuration
## Step 6: Common Pitfalls
Warn about:
- **Insufficient replicates**: R=100 is rarely enough. For coverage studies, you need R >= 1,000.
- **Ignoring Monte Carlo error**: Always report MCSE. A coverage of 0.94 with MCSE=0.007 is consistent with 0.95.
- **Conditioning bias**: If you filter out "non-convergent" replicates, the remaining sample is biased. Report the rejection rate.
- **Single parameter configuration**: Results at one parameter value do not generalize. Test across a range.
- **Floating-point issues**: For extreme parameter values, numerical issues can corrupt results. Include sanity checks.
## Step 7: Update State File
If `.papermill/state.md` exists, register the simulation (Edit tool) under `experiments`. If it does not exist, skip registration and suggest running `/papermill:init`.
The entry uses the standard experiment schema with an optional `config` block for simulation-specific parameters:
```yaml
experiments:
- name: "simulation-name"
type: "simulation"
hypothesis: "Empirical covariance matches theoretical FIM as n grows"
status: "planned"
script: "research/simulate_covariance.R"
last_run: null
config: # simulation-specific extension, not in the base experiment schema
replications: 5000
sample_sizes: [50, 100, 200, 500, 1000]
parameter_configs: 3
```
Append a timestamped note documenting the simulation design.
## Step 8: Suggest Next Steps
Based on the simulation status, suggest the most relevant next step:
- **Implement**: "Write the simulation script. Start with a small pilot (R=100) to debug before the full run."
- If the simulation validates a proof → "Once results confirm the theory, integrate both the proof and simulation evidence into the paper. Use `/papermill:proof` if the proof itself needs work."
- If simulation results are surprising or contradict theory → "The simulation suggests the theoretical result may need revisiting. Use `/papermill:proof` to re-examine the proof's assumptions."
- If results are written up → "Use `/papermill:review` to get feedback on the presentation of simulation results."
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.