A source tells pract_test() where the bits to test come from.
pract_raw() reads raw bytes, from a raw vector or a binary connection,
in order. pract_fun() calls an R function for more bits each time the
test needs them. pract_rng() draws from one of R's own generators, and
pract_interleave() combines sources word by word.
Arguments
- x
A raw vector, or a connection to read bytes from.
- f
A function of one argument,
n, returningnwords ofbitsbits: an integer vector of lengthnwhenbitsis 32, or a raw vector ofn * bits / 8bytes for anybits. Integers are taken as their 32-bit patterns, soNAis the word0x80000000.- bits
The size in bits of the words
freturns: 8, 16, 32 or 64. PractRand folds its tests to the word size;pract_raw()sources have no word size, as with PractRand'sRNG_test stdin.
Details
A raw vector or connection that ends before the test does ends the run
early; see pract_test(). A raw vector source can be used for several
runs, each reading from the start. A connection that is not open is opened
in binary mode for the run and closed after it, which destroys it, as
readLines() does, so it serves one run; an open connection is read from
where it is and left open.
See also
Other sources:
pract_interleave(),
pract_rng()
Examples
pract_raw(as.raw(sample(0:255, 1024, replace = TRUE)))
#> <zurngtest_source> raw vector of 1024 bytes
# R's own generator, as bytes
pract_fun(
function(n) as.raw(sample.int(256L, n, replace = TRUE) - 1L),
bits = 8
)
#> <zurngtest_source> function function(n) as.raw(sample.int(256L, n, replace = TRUE) - 1L), 8-bit words