## Create discrete distribution with given probability vector
pv <- c(1.,2.,1.5,0.,3.,1.2) ## PV need not be normalized
dpv <- new("unuran.discr",pv=pv)
## Make generator (using method DGT)
unr <- unuran.new(dpv, "dgt")
## Draw sample of size 100
x <- unuran.sample(unr, 100)
## Create discrete distribution with given probability mass function
pmf <- function(x) dbinom(x,100,0.3)
dpmf <- new("unuran.discr",pmf=pmf,lb=0,ub=100)
## Make generator (using method DGT)
unr <- unuran.new(dpmf, "dgt")
## Draw sample of size 100
x <- unuran.sample(unr, 100)Run the code above in your browser using DataLab