Description Usage Arguments Details Value Examples
Generators which sample from a list or produce random
integer samples. Both single sample, with gen.element
;
and multi-sample, with gen.sample
and gen.subsequence
are supported; while gen.choice
is used to choose from
generators instead of examples.
1 2 3 4 5 6 7 8 9 10 11 | gen.element(x, prob = NULL)
gen.int(n, prob = NULL)
gen.choice(..., prob = NULL)
gen.subsequence(x)
gen.sample(x, size, replace = FALSE, prob = NULL)
gen.sample.int(n, size, replace = FALSE, prob = NULL)
|
x |
a list or vector to sample an element from. |
prob |
a vector of probability weights for obtaining the elements of the vector being sampled. |
n |
the number which is the maximum integer sampled from. |
... |
generators to sample from |
size |
a non-negative integer or a generator of one, giving the number of items to choose. |
replace |
Should sampling be with replacement? |
These generators implement shrinking.
gen.element
returns an item from the list
or vector; gen.int
, an integer up to the value
n; gen.choice
, a value from one of given selected
generators; gen.subsequence
an ordered subsequence
from the input sequence; and gen.sample
a list or
vector (depending on the input) of the inputs.
For gen.element
and gen.choice
, shrinking
will move towards the first item; gen.int
will
shrink to 1; gen.subsequence
will shrink the list
towards being empty; and gen.sample
will shrink
towards the original list order.
1 2 3 4 5 6 | gen.element(1:10) # a number
gen.element(c(TRUE,FALSE)) # a boolean
gen.int(10) # a number up to 10
gen.choice(gen.element(1:10), gen.element(letters))
gen.choice(NaN, Inf, gen.unif(-10, 10), prob = c(1,1,10))
gen.subsequence(1:10)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.