two.envelopes <- function(){ x <- (rnorm(1)) x <- (abs(as.numeric(format(round(x, 3)))))*10 #randomly selects a number #limits the number of decimal places x can have and muiltples x by 10 to simluate realistic dollar values. p <- c(x,2*x) A <- sample(p, 1, replace=F) #creates a vector with x and 2x then randomly selects one for A. if (A == x) { B <- 2*x } else { (B <- x) } return(c(A,B)) } #sets the value for B based on: if A = x then B = 2x or if A = 2x then B = x g <- t(replicate(100, two.envelopes())) head(g) #results [,1] [,2] [1,] 5.23 10.46 [2,] 5.48 10.96 [3,] 25.60 12.80 [4,] 6.17 12.34 [5,] 3.88 7.76 [6,] 7.59 15.18
two.envelopes <- function(){ x <- (runif(1)) x <- (abs(as.numeric(format(round(x, 3)))))*10 #randomly selects a number #limits the number of decimal places x can have and muiltples x by 10 to simluate realistic dollar values. p <- c(x,2*x) A <- sample(p, 1, replace=F) #creates a vector with x and 2x then randomly selects one for A. if (A == x) { B <- 2*x } else { (B <- x) } return(c(A,B)) } #sets the value for B based on: if A = x then B = 2x or if A = 2x then B = x g <- t(replicate(100, two.envelopes())) head(g) #results [,1] [,2] [1,] 27.20 13.60 [2,] 28.72 14.36 [3,] 12.49 24.98 [4,] 12.95 25.90 [5,] 61.18 30.59 [6,] 2.66 1.33
two.envelopes<- function(){ x <- (rcauchy(1, location = 0, scale = 1)) x <- (abs(as.numeric(format(round(x, 3)))))*10 #randomly selects a number #limits the number of decimal places x can have and muiltples x by 10 to simluate realistic dollar values. p <- c(x,2*x) A <- sample(p, 1, replace=F) #creates a vector with x and 2x then randomly selects one for A. if (A == x) { B <- 2*x } else { (B <- x) } return(c(A,B)) } #sets the value for B based on: if A = x then B = 2x or if A = 2x then B = x g <- t(replicate(100, two.envelopes())) head(g) [,1] [,2] [1,] 10.22 20.44 [2,] 24.54 12.27 [3,] 2.05 4.10 [4,] 8.96 4.48 [5,] 15.44 7.72 [6,] 13.74 27.48
two.envelopes <- function(){ x <- (sample(1:100, 1)) #randomly selects a number p <- c(x,2*x) A <- sample(p, 1, replace=F) #creates a vector with x and 2x then randomly selects one for A. if (A == x) { B <- 2*x } else { (B <- x) } return(c(A,B)) } #sets the value for B based on: if A = x then B = 2x or if A = 2x then B = x g <- t(replicate(100, two.envelopes())) head(g) #results [,1] [,2] [1,] 27 54 [2,] 136 68 [3,] 33 66 [4,] 14 28 [5,] 30 60 [6,] 57 114
Get involved in philosophical discussions about knowledge, truth, language, consciousness, science, politics, religion, logic and mathematics, art, history, and lots more. No ads, no clutter, and very little agreement — just fascinating conversations.