‘A random variable is not random and not a variable’
“A random variable is not random and not a variable”. Yep, it’s a random number generator or a function. Lol, just for fun, let’s make a random variable into an actual random variable (a code variable that emits a random value every time it is evaluated):
makeActiveBinding("die_value", function(x) sample(1:6, 1), .GlobalEnv)
die_value
#> [1] 4
c(die_value, die_value, die_value, die_value)
#> [1] 5 1 3 6
mean(replicate(1000, die_value))
#> [1] 3.406
mean(1:6)
#> [1] 3.5
Leave a comment