ars: Implementing an Adaptive-Rejection Sampler

Description Usage Arguments Value Author(s) References Examples

View source: R/ars.R

Description

Adaptive-Rejection Sampler

Usage

1
Implementing an Adaptive-Rejection Sampler

Arguments

density

A probability density function

n

Number of samples to generate

lb

The lower bound of the domain

ub

The upper bound of the domain

Value

n samples from the probability density function

Author(s)

Rachel Hu, Lin Yang, Jonathan Chen

References

Adaptive Rejection Sampling for Gibbs Sampling W. R. Gilks and P. Wild (1992)

Examples

1
2
3
4
g <- function(x){return(dnorm(x,0,1))}
ars(g, 500, -1, 10)
f <- function(x){return(dgamma(x, 2, rate = 1))}
ars(f, 1000, 1, 5)

jonathanchen888/ars documentation built on May 13, 2019, 9:52 p.m.