gensample: Generate random samples from a law added in the package.

Description Usage Arguments Value Author(s) References See Also Examples

Description

Generate random samples from a law added in the package as a C function.

Usage

1
gensample(law.index,n,law.pars = NULL,check = TRUE, center=FALSE, scale=FALSE)

Arguments

law.index

law index as given by function getindex.

n

number of observations to generate.

law.pars

vector of parameters for the law. The length of this parameter should not exceed 4.

check

logical. If TRUE, we check if law.index belongs to the list of laws. If FALSE, we pass on this verification, this will reduce the simulation time.

center

Logical. Should we center the data generated

scale

Logical. Should we center the data generated

Value

A list containing the random sample and the vector of parameters used for the chosen law.

Author(s)

P. Lafaye de Micheaux, V. A. Tran

References

Pierre Lafaye de Micheaux, Viet Anh Tran (2016). PoweR: A Reproducible Research Tool to Ease Monte Carlo Power Simulation Studies for Goodness-of-fit Tests in R. Journal of Statistical Software, 69(3), 1–42. doi:10.18637/jss.v069.i03

See Also

See checklaw

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# This is good to check if the generator of the given law has been well coded.

res <- gensample(2,10000,law.pars=c(-5,2),check=TRUE)
res$law
res$law.pars
mean(res$sample)
sd(res$sample)

# See function checklaw() in this package.
hist(gensample(2,10000,law.pars=c(0,1),check=TRUE)$sample,prob=TRUE,breaks=100,main="Density
histogram of the N(0,1) distribution")
curve(dnorm(x),add=TRUE,col="blue")

PoweR documentation built on May 2, 2019, 2:09 p.m.

Related to gensample in PoweR...