Learn R Programming

PoweR (version 1.0.7)

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

Description

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

Usage

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.

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

Run this code
# NOT RUN {
# 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")

# }

Run the code above in your browser using DataLab