adaptive-rejection-sampler

Implement adaptive rejection sampling for log-concave distributions in R.

Updated Feb 24, 2026
One-click install
npx skills add https://github.com/Zurybr/lefarma-skills --skill adaptive-rejection-sampler-zurybr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adaptive-rejection-sampler
Source: https://github.com/Zurybr/lefarma-skills/tree/main/letta/benchmarks/trajectory-only/adaptive-rejection-sampler
Command: npx skills add https://github.com/Zurybr/lefarma-skills --skill adaptive-rejection-sampler-zurybr

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides guidance for implementing adaptive rejection sampling (ARS) algorithms, which are essential for efficiently generating random samples from complex log-concave probability distributions, particularly in statistical computing.

Core Features & Use Cases

  • ARS Algorithm Implementation: Detailed steps and pseudocode for constructing adaptive upper and lower bounds (envelopes).
  • Log-Concavity Verification: Guidance on correctly checking the log-concavity requirement of target distributions.
  • Domain and Boundary Handling: Strategies for managing unbounded, lower-bounded, upper-bounded, and fully bounded domains.
  • Use Case: When performing Bayesian inference or Monte Carlo simulations that require sampling from custom, log-concave probability densities in R, this skill helps ensure a robust and correct implementation.

Quick Start

Implement the adaptive rejection sampling algorithm in R, ensuring proper handling of log-concavity and domain boundaries.

Frequently Asked Questions about adaptive-rejection-sampler

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

FAQPage Schema
How does adaptive rejection sampling work for log-concave distributions?

Adaptive rejection sampling works by constructing adaptive upper and lower bounds, or envelopes, around a log-concave probability density function to efficiently generate random samples. The envelopes are refined iteratively as more samples are drawn, improving efficiency.

How do I implement adaptive rejection sampling in R for custom probability distributions?

To implement adaptive rejection sampling in R, follow detailed algorithm steps and pseudocode to construct envelopes, verify log-concavity, and handle domain boundaries. Proper implementation ensures robust sampling for Monte Carlo simulations and Bayesian inference.

When do I need adaptive rejection sampling for Monte Carlo methods?

You need adaptive rejection sampling for Monte Carlo methods when generating random samples from complex, custom log-concave probability distributions where standard sampling techniques are inefficient or fail. It is particularly useful for Bayesian inference requiring custom densities.

How do I verify log-concavity for a target probability distribution before sampling?

To verify log-concavity for a target probability distribution, check whether the logarithm of the density function is concave. The skill provides specific guidance on correctly checking this log-concavity requirement, which is mandatory for the algorithm to work.

How do I handle unbounded or bounded domains when using adaptive rejection sampling?

Handle unbounded, lower-bounded, upper-bounded, and fully bounded domains by applying specific domain and boundary handling strategies provided during implementation. These strategies ensure the adaptive envelopes correctly bound the target distribution.

What are common pitfalls and performance considerations for rejection sampling algorithms?

Common pitfalls and performance considerations for rejection sampling algorithms include failing to verify log-concavity, improperly handling domain boundaries, and inefficient envelope construction. The skill details these issues to ensure a correct and performant implementation.