prob (version 1.0-1)

sim: Simulate Draws from a Sample Space

Description

Simulates the experiment of drawing from a sample space.

Usage

sim(x, …)

# S3 method for default sim(x, ntrials, …)

# S3 method for ps sim(x, ntrials, …)

Arguments

x

a probability space or a subset of one.

ntrials

number of times to repeat the experiment.

further arguments to be passed to or from other methods.

Value

A data frame if space is a data frame, or a list if space is of class ps.

Details

The sim() function is a wrapper for sample(), except that it strips the probs component from the result and (if x is a data frame) renames the rownames of the data frame consecutively from 1:ntrials.

See Also

empirical

Examples

Run this code
# NOT RUN {
S <- cards(makespace = TRUE)
sim(S, ntrials = 5)

T <- urnsamples(S, 2)
U <- probspace(T)
sim(U, ntrials = 4)
# }

Run the code above in your browser using DataLab