gensample {PoweR} | R Documentation |
Generate random samples from a law added in the package as a C function.
gensample(law.index,n,law.pars = NULL,check = TRUE, center=FALSE, scale=FALSE)
law.index |
law index as given by function
|
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 |
center |
Logical. Should we center the data generated |
scale |
Logical. Should we center the data generated |
A list containing the random sample and the vector of parameters used for the chosen law.
P. Lafaye de Micheaux, V. A. Tran
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 checklaw
# 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")