adaptive-rejection-sampler

Implement Adaptive Rejection Sampling for log-concave distributions with envelope construction.

134|21|Updated Nov 12, 2025
One-click install
npx skills add https://github.com/letta-ai/skills --skill adaptive-rejection-sampler
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adaptive-rejection-sampler
Source: https://github.com/letta-ai/skills/tree/main/ai/benchmarks/letta/terminal-bench-2/trajectory-only/adaptive-rejection-sampler
Command: npx skills add https://github.com/letta-ai/skills --skill adaptive-rejection-sampler

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides procedural guidance for implementing Adaptive Rejection Sampling (ARS) for log-concave distributions, including envelope construction and adaptive updates.

Core Features & Use Cases

  • Algorithm Design: Build and update piecewise linear envelopes.
  • Sampling Strategy: Draw samples via exponential of upper hull with acceptance tests.
  • Verification: Test with standard log-concave distributions like exponential and Gaussian.

Quick Start

Implement ARS for a log-concave target distribution and generate 1000 samples.

Frequently Asked Questions about adaptive-rejection-sampler

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement adaptive rejection sampling for log-concave distributions?

Adaptive rejection sampling (ARS) generates samples from log-concave distributions by constructing a piecewise linear envelope using tangent lines at evaluated points. The algorithm iteratively refines this envelope, drawing candidates from the upper hull and accepting or rejecting them based on acceptance tests, then updating the envelope with rejected points to improve efficiency over iterations.

What is log-concavity and why does it matter for sampling?

Log-concavity means the logarithm of a probability density function is concave, ensuring tangent lines form valid upper and lower bounds. This property enables ARS to construct guaranteed envelopes for rejection sampling, making the algorithm both theoretically sound and computationally efficient for distributions like exponential and Gaussian.

How do I verify that my target distribution is log-concave?

Verify log-concavity by confirming the second derivative of the log density is non-positive across the domain, or test numerically with tolerance thresholds. ARS implementations should include verification routines and test against standard log-concave distributions like exponential and Gaussian to confirm envelope construction is correct.

What initialization strategies work best for envelope construction in ARS?

Initialization requires selecting starting points where the tangent lines are evaluated to build the initial envelope. Effective strategies include spacing points uniformly across the support or using quantiles, ensuring the envelope adequately bounds the target density before sampling begins.

How do I handle performance optimization and timeouts in ARS implementations?

Optimize ARS by tuning iteration limits to balance envelope quality against computational cost and implementing timeout safeguards to prevent runaway sampling. Monitor acceptance rates and envelope tightness; if acceptance drops or iterations exceed thresholds, adjust initialization or point-selection strategies.

Can I use adaptive rejection sampling for distributions beyond exponential and Gaussian?

ARS applies to any log-concave distribution. Beyond exponential and Gaussian, it works with log-normal, Laplace, and other log-concave densities. Verify log-concavity for your target, test envelope bounds numerically with tolerances, and validate sampling output against known statistics before production use.