Token导航 LogoToken导航TokenDH.com
AI 工具执行命令github未标认证来源可访问clear审计通过

mcmc-sampling-stanmcmc sampling stan 命令行

Agent Skill

mcmc-sampling-stan 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

874

周安装

35

GitHub Stars

93

下载量

283
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:mcmc-sampling-stan(mcmc sampling stan 命令行)
来源仓库:https://github.com/letta-ai/skills
仓库路径:skills/mcmc-sampling-stan
安装命令:
npx skills add https://github.com/letta-ai/skills --skill mcmc-sampling-stan
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/letta-ai/skills --skill mcmc-sampling-stan

简介

mcmc-sampling-stan 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更进行整理。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装,需确认权限与维护状态。
  • 使用前建议核验具体用法,避免触发不必要的联网或文件操作。
  • 涉及敏感数据时应先确认脱敏边界与最小权限原则。

SKILL.md

MCMC Sampling with Stan

Overview

This skill provides procedural guidance for implementing Markov Chain Monte Carlo (MCMC) sampling using Stan and RStan. It covers the complete workflow from environment setup through model specification to convergence validation, with emphasis on avoiding common pitfalls in hierarchical Bayesian modeling.

When to Use This Skill

  • Installing and configuring RStan in R environments
  • Writing Stan models for Bayesian inference
  • Implementing hierarchical/multilevel models
  • Configuring MCMC sampling parameters
  • Diagnosing and validating MCMC convergence

Pre-Implementation Checklist

Before writing any code, verify the following in order:

1. System Dependencies First

Critical: Always check system dependencies before attempting R package installation.

# Check for C++ compiler and build tools
which g++ || which clang++
dpkg -l | grep -E "(build-essential|r-base-dev)" # Debian/Ubuntu

Required system packages for RStan:

  • build-essential or equivalent C++ toolchain
  • r-base-dev for R development headers
  • Sufficient memory (Stan compilation is memory-intensive)

2. RStan Installation Strategy

Install RStan with explicit version pinning when specified:

# If specific version required (e.g., 2.32.7)
install.packages("rstan", repos = "https://cloud.r-project.org/")

# Verify installation and version
library(rstan)
packageVersion("rstan")

Common installation failures:

  • Missing C++ compiler → Install build-essential first
  • Compilation errors → Check g++ version compatibility
  • Memory exhaustion → Close other applications, increase swap

3. Environment Verification

Before proceeding with model development:

# Verify RStan loads without errors
library(rstan)

# Test Stan compilation with minimal model
stan_model(model_code = "parameters { real x; } model { x ~ normal(0,1); }")

Stan Model Specification

Hierarchical Model Structure

For hierarchical Bayesian models, follow this block structure:

data {
  // Declare all input data with types and constraints
  int<lower=0> N;           // Number of observations
  int<lower=0> y[N];        // Observed counts
  int<lower=0> n[N];        // Trial sizes
}

parameters {
  // Hyperparameters (population-level)
  real<lower=0> alpha;
  real<lower=0> beta;

  // Group-level parameters
  real<lower=0, upper=1> theta[N];
}

model {
  // Hyperprior (if using custom/improper priors)
  // Example: p(α,β) ∝ (α+β)^(-5/2)
  target += -2.5 * log(alpha + beta);

  // Prior for group parameters
  theta ~ beta(alpha, beta);

  // Likelihood
  y ~ binomial(n, theta);
}

Custom Prior Implementation

When implementing custom or improper priors:

Prior FormStan Implementation
p(x) ∝ x^atarget += a * log(x);
p(x) ∝ (a+b)^ctarget += c * log(a + b);
Flat/improperNo explicit statement needed

Document the mathematical transformation: Always comment the relationship between the mathematical prior and the target += statement.

MCMC Sampling Configuration

Recommended Control Parameters

For hierarchical models with potential sampling difficulties:

fit <- sampling(
  model,
  data = stan_data,
  chains = 4,                    # Multiple chains for convergence assessment
  iter = 100000,                 # Total iterations (including warmup)
  seed = 1,                      # Reproducibility
  control = list(
    adapt_delta = 0.95,          # Increase for divergent transitions
    max_treedepth = 15           # Increase for complex posteriors
  )
)

Parameter Selection Rationale

ParameterDefaultWhen to IncreaseWhy
adapt_delta0.8Divergent transitionsSmaller step sizes improve exploration
max_treedepth10"Maximum treedepth" warningsAllows longer trajectories
iter2000Low effective sample sizeMore samples for inference
warmupiter/2Slow convergenceMore adaptation time

Warmup Considerations

  • Default warmup is 50% of iter
  • For 100,000 iterations: 50,000 warmup + 50,000 sampling per chain
  • Explicitly specify if different warmup proportion needed:
sampling(..., iter = 100000, warmup = 25000)  # 25% warmup

Convergence Diagnostics

Required Validation Steps

Always verify these after sampling:

# 1. Check Rhat (potential scale reduction factor)
summary(fit)$summary[, "Rhat"]
# Target: All Rhat < 1.01 (ideally < 1.005)

# 2. Check effective sample size
summary(fit)$summary[, "n_eff"]
# Target: n_eff > 400 for reliable inference

# 3. Check for divergent transitions
get_num_divergent(fit)
# Target: 0 divergent transitions

# 4. Check treedepth saturation
get_num_max_treedepth(fit)
# Target: 0 or minimal saturation

Diagnostic Interpretation

IssueIndicatorResolution
Poor mixingRhat > 1.01Increase iter, reparameterize
Inefficient samplingLow n_effIncrease iter, adjust adapt_delta
Geometric problemsDivergent transitionsIncrease adapt_delta, reparameterize
Complex posteriorMax treedepth hitsIncrease max_treedepth

Common Pitfalls and Solutions

1. Installation Order Errors

Wrong: Install RStan → Installation fails → Check dependencies Right: Check dependencies → Install prerequisites → Install RStan

2. Missing Convergence Checks

Wrong: Run sampling → Extract means → Report results Right: Run sampling → Check Rhat/n_eff/divergences → Validate → Extract results

3. Improper Prior Issues

When using improper priors like p(α,β) ∝ (α+β)^(-5/2):

  • Ensure parameters are constrained (<lower=0>)
  • Verify posterior is proper (converges)
  • Check for boundary behavior near zero

4. Command Syntax in Shell

Avoid piping R output with shell redirection that causes parsing errors:

# Problematic
Rscript -e "code" 2>&1 | grep ...

# Safer
Rscript -e "code" > output.txt 2>&1
grep ... output.txt

Verification Strategy

Stepwise Verification Approach

  1. Environment: Verify RStan installation before model development
  2. Compilation: Test Stan model compiles without errors
  3. Sampling: Run with reduced iterations first to catch issues
  4. Diagnostics: Check all convergence metrics before trusting results
  5. Results: Extract posteriors only after validation passes

Sanity Checks for Results

  • Posterior means should be plausible given prior and data
  • 95% credible intervals should have reasonable width
  • Multiple chains should show similar posteriors
  • Results should be consistent across different seeds (approximately)

References

For detailed Stan documentation and examples, consult:

  • Stan User's Guide: Model specification and best practices
  • RStan Getting Started: Installation and basic usage
  • Stan Functions Reference: Available distributions and functions

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

30.21%
按下载量换算85

Gemini CLI

22.72%
按下载量换算64

Antigravity

17.15%
按下载量换算49

windsurf

12.42%
按下载量换算35

OpenCode

7.37%
按下载量换算21

Codex

3.79%
按下载量换算11

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/letta-ai/skills --skill mcmc-sampling-stan;npx skills add letta-ai/skills --skill "mcmc-sampling-stan" 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills