Description Usage Arguments Value Examples
View source: R/random_variables.R
A random variable is a function which maps an outcome of a probability space to a number. Simulating a random variable is a two-step process: first, a draw is taken from the underlying probability space; then, the function is applied to that draw to obtain the realized value of the random variable.
1 |
probSpace |
(ProbabilitySpace): the underlying probability space of the random variable. |
fun |
(function, optional): a function that maps draws from the probability space to numbers. |
A RV
1 2 3 4 5 6 7 8 9 10 11 12 | # a single draw is a sequence of 0s and 1s, e.g., (0, 0, 1, 0, 1).
P = BoxModel(c(0, 1), size=5)
# X counts the number of 1s in the draw, e.g., 5
X = RV(P, sum)
# the function is the identity, so Y has a Normal(0, 1) distribution
Y = RV(Normal(0, 1)
# a single draw from BivariateNormal is a tuple of two numbers
P = BivariateNormal()
# Z is the smaller of the two numbers
Z = RV(P, min)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.