Token导航 LogoToken导航TokenDH.com
开发权限需确认github未标认证来源可访问clear审计通过

adaptive-rejection-sampler自适应拒绝采样器

Agent Skill

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

总安装

808

周安装

33

GitHub Stars

93

下载量

259
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/letta-ai/skills --skill adaptive-rejection-sampler

简介

adaptive-rejection-sampler 提供自适应拒绝采样算法的实现指导与优化建议,适用于统计模拟与概率建模。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中构建从对数凹分布采样的工具链或调试现有采样器性能。
  • 涵盖包络线构造、迭代更新与收敛验证等关键环节,强调过程控制与数值稳定性。
  • 安装命令为 npx skills add https://github.com/letta-ai/skills --skill adaptive-rejection-sampler,需配合 Python 或 R 环境使用。
  • 使用时应验证目标分布的数学性质与采样精度要求,避免因近似误差导致结果偏差。

SKILL.md

Adaptive Rejection Sampler

Overview

This skill provides guidance for implementing Adaptive Rejection Sampling (ARS) algorithms. ARS is a method for generating samples from log-concave probability distributions by constructing piecewise linear upper and lower envelopes of the log-density function. The skill focuses on procedural approaches, performance optimization, and verification strategies rather than providing implementation code.

When to Use This Skill

Use this skill when:

  • Implementing adaptive rejection sampling from scratch
  • Working with log-concave distribution samplers
  • Building statistical sampling algorithms that require envelope construction
  • Debugging or optimizing existing ARS implementations
  • The task involves R, Python, or other statistical computing environments

Implementation Approach

Phase 1: Algorithm Design Before Coding

Before writing any code:

  1. Understand the mathematical foundations

- Review the ARS algorithm requirements for log-concave functions - Understand how piecewise linear envelopes are constructed from tangent lines - Identify the squeeze function optimization

  1. Design with performance in mind

- Plan iteration limits and safeguards from the start - Consider worst-case computational complexity of the sampling loop - Design for timeout constraints that may be stricter than development testing

  1. Plan the module structure

- Log-concavity verification module - Envelope construction and update module - Sampling loop with rejection logic - Initialization point selection

Phase 2: Critical Implementation Considerations

Log-Concavity Checking

When implementing log-concavity verification:

  • Use appropriate tolerance values for numerical comparison
  • Consider that some valid distributions have constant second derivatives (e.g., exponential distribution)
  • Use <= tolerance instead of strict < comparisons when checking for non-positive second derivatives
  • Test with edge cases like exponential, normal, and gamma distributions

Initialization Points

Proper initialization significantly affects sampling quality and performance:

  • Handle shifted distributions by adjusting initialization points relative to the mode
  • Consider the support bounds when selecting initial points
  • Use multiple initial points to ensure good envelope coverage
  • Test with distributions that have modes far from the origin

Iteration Limits and Safeguards

Critical for preventing infinite loops and timeouts:

  • Implement maximum iteration limits in all sampling loops
  • Add progress indicators or logging for long-running computations
  • Include timeout protection mechanisms
  • Design early exit conditions for convergence

Phase 3: Performance-First Development

Timeout Considerations

  • External test frameworks may use shorter timeouts than development testing
  • If development tests use 180-second timeouts, production may use 60 seconds
  • Profile performance early to catch issues before they become blocking
  • Test with varying timeout constraints to ensure robustness

Computational Efficiency

  • Analyze the computational complexity of the sampling loop
  • Optimize envelope updates to minimize recalculation
  • Consider caching frequently computed values
  • Profile with realistic sample sizes

Verification Strategies

Unit Testing Approach

  1. Test each module independently

- Log-concavity checker with known log-concave and non-log-concave functions - Envelope construction with simple distributions - Sampling loop with controlled random seeds

  1. Test known distributions

- Standard normal distribution - Exponential distribution (constant second derivative edge case) - Truncated normal distributions - Gamma distributions with various parameters

  1. Test edge cases explicitly

- Non-function inputs - Negative sample counts - Invalid bounds (lower > upper) - Very small and very large sample sizes

Performance Testing

  • Match testing timeouts to expected production constraints
  • Test worst-case behavior, not just average case
  • Profile with different random seeds to catch stochastic failures
  • Measure time per sample to identify performance degradation

Integration Testing

  • Test the complete pipeline from input to samples
  • Verify statistical properties of generated samples (mean, variance, distribution shape)
  • Use statistical tests (KS test, chi-square) to verify sample quality
  • Test with distributions that have known analytical moments

Common Pitfalls and Mistakes

Critical Mistakes to Avoid

  1. Missing iteration limits

- Always include maximum iteration safeguards in rejection sampling loops - An unbounded rejection loop will cause timeouts on difficult distributions

  1. Inadequate performance testing

- Development tests passing does not guarantee production success - Test with the same timeout constraints as the target environment

  1. Tolerance issues in log-concavity checking

- Strict inequality checks (< 0) may incorrectly reject valid distributions - Use tolerant comparisons (<= tolerance) for numerical stability

  1. Poor initialization for shifted distributions

- Hard-coded initialization points fail for distributions with non-zero modes - Always compute initialization relative to the distribution's characteristics

  1. Incomplete file verification

- After writing large code blocks, verify the complete content was written - Truncated files can cause subtle bugs

Debugging Approach

When tests fail or timeout:

  1. Systematic debugging over trial-and-error

- Understand root causes before implementing fixes - Use logging to identify where time is being spent

  1. Isolate the problematic component

- Test log-concavity checking separately - Test envelope construction separately - Test sampling loop with mock envelopes

  1. Check for infinite loops

- Add iteration counters to all loops - Log when iteration limits are approached - Verify exit conditions are reachable

Quality Checklist

Before considering the implementation complete:

  • All sampling loops have maximum iteration limits
  • Log-concavity checking uses appropriate tolerances
  • Initialization points adapt to distribution characteristics
  • Performance tested with target timeout constraints
  • Edge cases for invalid inputs are handled
  • Statistical properties of samples verified
  • Code verified to be completely written (no truncation)
  • Tested with multiple random seeds

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

04

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

能力 5

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

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

平台分布

Claude Code

29.66%
按下载量换算77

Gemini CLI

25.55%
按下载量换算66

Codex

16.39%
按下载量换算42

Antigravity

13.95%
按下载量换算36

OpenCode

7.56%
按下载量换算20

windsurf

3.45%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

权限需确认

当前来源未能明确判断权限范围,默认进入异常复核队列。

安装前确认

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

来源信息

继续浏览同类 Skills