rejectionSampler: math4800 project this file implemnts a funciton to sample...

Description Usage Arguments Value Examples

Description

This function returns a vector with n elemtns from a continus random variable

Usage

1
rejectionSampler(n, pdf, lower, upper, C)

Arguments

n

number of observations. n must be an integer >0

pdf

a function that is the pdf of the distribution.

lower

lower and upper limits of the of the distribution. Must be finite such that P(a ≤ X ≤ b \cap a ≤ Y ≤ b) = 1.

C

a numeric such that f(x,y) ≤ C for all values of x.

lower

lower and upper limits of the distribution

Value

data.frame of random deviate pairs

Examples

1
2
3
rejectionSampler(n = 1000, pdf = mypdf, lower = 0, upper = 2, C = 1)
this is an exact bounds so that the pdf integrates to 1
rejectionSampler(n = 1000, pdf = normpdf, lower = -100, upper = 100, C = 1)

brucker3/math4800 documentation built on May 16, 2019, 7:14 p.m.