Next: rsolve()
Up: MacAnova Help File
Previous: rpoi()
Contents
Usage:
y <- rsample(x,n) or y <- rsample(x,n,T), REAL vector or matrix x,
positive integer n
y <- rsample(x,n,F) requires n <= nrows(x)
|
Keywords:
random numbers
rsample() is a macro you can use to select a random sample with or
without replacement from the rows of a REAL matrix or vector.
y <- rsample(x, n) and rsample(x, n, T) both select a random sample of
size n from the rows of REAL matrix x. n is a positive integer.
Sampling is *with* replacement.
y <- rsample(x, n, F) does the same, except that sampling is without
replacement. It is an error if n > nrows(x).
In both usages, y will be a REAL vector of length n or a REAL n by
ncols(x) matrix.
The following selects a random sample of size 5 drawn without
replacement from {1,2,...,20}:
Cmd> y <- rsample(run(20),5,F)
Cmd> y
(1) 11 10 8 3 18
See also runi(), rnorm().
Gary Oehlert
2003-01-15