rsim: Simulate n independent trials from a random variable X:

Description Usage Arguments Examples

Description

Simulate n independent trials from a random variable X:

Usage

1
rsim(X, n)

Arguments

X

A random variable

n

The number of independent trials to simulate

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
X.Bern <- RV(c(1,0), c(.5,.5))
X.Bern.sim100 <- rsim(X.Bern, 100)

X.loaded.die <- RV(1:6, odds = c(1,1,1,1,2,4))
X.loaded.die.sim100 <- rsim(X.loaded.die, 100)

# The function 'rsim()' attaches the probabilities as names to the random draws.
# To get the values only, use 'as.vector()':
as.vector(X.Bern.sim100)
as.vector(X.loaded.die.sim100)

erichare/discreteRV documentation built on May 16, 2019, 8:27 a.m.