Search

  • Mathematical Conundrum or Not? Number Six

    I have been messing with this in R, and wrote a function which simulates the game. Note that is not a simple repeated sample from a predefined sample space. It simulates the game, by selecting X randomly then randomly places X or 2X into A. Then X or 2X into B based on what is in A. It then returns the value of both A and B.

    The function, which is called two.envelopes, is one go at the game, and then the function replicate can be used to run it several times in a row. Which I did then output those to a matrix.

    I ran the game simulation under 4 different conditions: Where X is chosen from a normal distribution, where X is chosen from a uniform distribution, where is X is chosen from a Cauchy distribution and where X is sampled from an interval scale. The function could be used as well to do actual statistical analyses either Classical or Bayesian, by generating enough simulated data to support such an approach.

    I know these efforts will be lost on some people, but it does provide a visual summary which demonstrates the distribution in which X was selected from is not significant when assessing the possible outcome of envelope A and B concerning X or 2X.

    Also, this gives results that can be reviewed which are not dependent on defining a sample space or on calculating an expected value.

    Normal Distribution:

    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
    



    Uniform distribution:

    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
    
    

    Cauchy distribution:

    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
    
    

    Interval Scale:

    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
    

    The thing to notice here is that in all cases the absolute value of the difference between column one and column two is always equal to the lesser of the two (save rounding errors). The lesser of the two is X.

Welcome to The Philosophy Forum!

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.