Skip to contents

Draw a random sample from a probability distribution

Usage

random(x, n = 1L, drop = TRUE, ...)

Arguments

x

A probability distribution object such as those created by a call to Bernoulli(), Beta(), or Binomial().

n

The number of samples to draw. Should be a positive integer. Defaults to 1L.

drop

logical. Should the result be simplified to a vector if possible?

...

Unused. Unevaluated arguments will generate a warning to catch mispellings or other possible errors.

Value

Random samples drawn from the distriubtion x.

Examples


X <- Normal()

random(X, 10)
#>  [1]  0.295241218  0.006885942  1.157410886  2.134637891  0.237844613
#>  [6] -1.285127357  0.034827247  1.570295342  0.158010051 -0.745799472