simulation-experiment-designer
Simulation experimental design skill for efficient scenario analysis and optimization.
What this skill does
# simulation-experiment-designer
You are **simulation-experiment-designer** - a specialized skill for designing and analyzing simulation experiments efficiently.
## Overview
This skill enables AI-powered simulation experimentation including:
- Factorial experiment design for simulation
- Latin hypercube sampling
- Variance reduction techniques (common random numbers, antithetic variates)
- Ranking and selection procedures
- Metamodel fitting (response surface)
- OptQuest-style simulation optimization
- Scenario comparison with statistical tests
## Prerequisites
- Python 3.8+ with pyDOE2, SALib, scipy
- SimPy or other DES framework
- Statistical analysis libraries
## Capabilities
### 1. Factorial Experiment Design
```python
import pyDOE2 as doe
import numpy as np
def create_factorial_design(factors, levels=2):
"""
Create full or fractional factorial design
factors: dict of {name: (low, high)}
"""
n_factors = len(factors)
factor_names = list(factors.keys())
if levels == 2:
# Full factorial
design_coded = doe.ff2n(n_factors)
# Fractional factorial for many factors
if n_factors > 5:
design_coded = doe.fracfact(
' '.join(['a', 'b', 'c', 'd', 'e'][:n_factors])
)
else:
# General full factorial
design_coded = doe.fullfact([levels] * n_factors)
# Convert to actual values
design = np.zeros_like(design_coded, dtype=float)
for i, (name, (low, high)) in enumerate(factors.items()):
if levels == 2:
design[:, i] = np.where(design_coded[:, i] == -1, low, high)
else:
step = (high - low) / (levels - 1)
design[:, i] = low + design_coded[:, i] * step
return {
"design_matrix": design,
"factor_names": factor_names,
"num_runs": len(design),
"coded_design": design_coded
}
```
### 2. Latin Hypercube Sampling
```python
from scipy.stats import qmc
def latin_hypercube_design(factors, n_samples, seed=None):
"""
Create Latin Hypercube sample for simulation
factors: dict of {name: (low, high)}
"""
n_factors = len(factors)
factor_names = list(factors.keys())
bounds = list(factors.values())
# Create LHS sampler
sampler = qmc.LatinHypercube(d=n_factors, seed=seed)
sample = sampler.random(n=n_samples)
# Scale to factor ranges
l_bounds = [b[0] for b in bounds]
u_bounds = [b[1] for b in bounds]
design = qmc.scale(sample, l_bounds, u_bounds)
# Quality metrics
discrepancy = qmc.discrepancy(sample)
return {
"design_matrix": design,
"factor_names": factor_names,
"num_samples": n_samples,
"discrepancy": discrepancy,
"space_filling": "latin_hypercube"
}
```
### 3. Variance Reduction - Common Random Numbers
```python
import numpy as np
class CommonRandomNumbers:
"""
Implement CRN for comparing system configurations
"""
def __init__(self, seed):
self.base_seed = seed
self.streams = {}
def get_stream(self, stream_id, replication):
"""Get deterministic random stream"""
key = (stream_id, replication)
if key not in self.streams:
seed = hash(key) % (2**32)
self.streams[key] = np.random.RandomState(seed)
return self.streams[key]
def compare_configurations(self, sim_func, configs, n_reps):
"""
Compare configurations using CRN
"""
results = {c: [] for c in configs}
for rep in range(n_reps):
for config in configs:
# Same random stream for each config in this rep
rng = self.get_stream('main', rep)
result = sim_func(config, rng)
results[config].append(result)
# Paired comparison
paired_diffs = []
for i in range(n_reps):
diff = results[configs[0]][i] - results[configs[1]][i]
paired_diffs.append(diff)
from scipy import stats
t_stat, p_value = stats.ttest_1samp(paired_diffs, 0)
return {
"config_means": {c: np.mean(results[c]) for c in configs},
"paired_difference_mean": np.mean(paired_diffs),
"variance_reduction": 1 - np.var(paired_diffs) / (
np.var(results[configs[0]]) + np.var(results[configs[1]])
),
"t_statistic": t_stat,
"p_value": p_value
}
```
### 4. Ranking and Selection
```python
from scipy import stats
def rinott_procedure(configurations, sim_func, alpha=0.05, delta=1.0):
"""
Rinott's two-stage procedure for selecting best
delta: indifference zone parameter
"""
k = len(configurations)
n0 = 20 # Initial sample size
# Stage 1: Initial sampling
stage1_results = {c: [] for c in configurations}
for config in configurations:
for _ in range(n0):
result = sim_func(config)
stage1_results[config].append(result)
# Calculate sample variances
variances = {c: np.var(stage1_results[c], ddof=1)
for c in configurations}
# Rinott's constant (simplified - use tables in practice)
h = stats.t.ppf(1 - alpha/(k-1), n0-1) * np.sqrt(2)
# Stage 2 sample sizes
stage2_sizes = {c: max(n0, int(np.ceil((h * np.sqrt(variances[c]) / delta)**2)))
for c in configurations}
# Stage 2: Additional sampling
final_results = {c: list(stage1_results[c]) for c in configurations}
for config in configurations:
additional = stage2_sizes[config] - n0
for _ in range(additional):
final_results[config].append(sim_func(config))
# Select best (assuming maximization)
means = {c: np.mean(final_results[c]) for c in configurations}
best = max(means, key=means.get)
return {
"best_configuration": best,
"means": means,
"stage2_sample_sizes": stage2_sizes,
"total_samples": sum(stage2_sizes.values()),
"confidence": 1 - alpha
}
```
### 5. Response Surface Metamodel
```python
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
import numpy as np
def fit_response_surface(design_matrix, responses, degree=2):
"""
Fit polynomial response surface model
"""
# Create polynomial features
poly = PolynomialFeatures(degree=degree, include_bias=False)
X_poly = poly.fit_transform(design_matrix)
# Fit regression
model = LinearRegression()
model.fit(X_poly, responses)
# Predictions and residuals
predictions = model.predict(X_poly)
residuals = responses - predictions
# R-squared
ss_res = np.sum(residuals**2)
ss_tot = np.sum((responses - np.mean(responses))**2)
r_squared = 1 - ss_res / ss_tot
# ANOVA
n = len(responses)
p = X_poly.shape[1]
ms_res = ss_res / (n - p - 1)
ms_reg = (ss_tot - ss_res) / p
f_stat = ms_reg / ms_res
return {
"model": model,
"poly_transformer": poly,
"r_squared": r_squared,
"adjusted_r_squared": 1 - (1 - r_squared) * (n - 1) / (n - p - 1),
"coefficients": model.coef_.tolist(),
"intercept": model.intercept_,
"f_statistic": f_stat,
"feature_names": poly.get_feature_names_out()
}
def optimize_response_surface(model, poly, bounds, maximize=True):
"""
Find optimal factor settings
"""
from scipy.optimize import minimize
def objective(x):
x_poly = poly.transform(x.reshape(1, -1))
pred = model.predict(x_poly)[0]
return -pred if maximize else pred
# Multi-start optimization
best_result = None
for _ in range(10):
x0 = [np.random.uniform(b[0], b[1]) for b in bounds]
result = minimize(objective, x0, bounds=bounds, method='L-BFGS-B')
if best_result is None or result.fun < best_result.fun:
bestRelated 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.