rej: use rejection method to get simulation data

Description Usage Arguments Value Examples

Description

use rejection method to get simulation data

Usage

1
rej(n, pdf, a, b, k)

Arguments

n

number of sample

pdf

pdf function

a

range of data

b

range of data

k

bound of pdf

Value

data

Examples

1
2
3
4
5
6
pdf <- function(x){
if(x>0&x<1){return(x)}
if(x>=1&x<2){return(2-x)}
return(0)
}
rej(10,pdf,0,2,2)

hans1996/simulation documentation built on June 18, 2019, 12:35 a.m.