Search

  • Mathematical Conundrum or Not? Number Six

    Something else I would like to point out, is that assuming that the probability of any given x must come from a discrete distribution is not necessarily true. In fact I used a selection method where the actual chance mechanism was applied to a continuous distribution in this very thread.


    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))
    }
    

    I used a continuous uniform distribution to randomly selected an x then formatted it into real dollar values. Now who is to say that such a chance mechanism was not used to fill the envelopes?

    If a probabilistic approach is to reason from a known population then the known population is x or 2x. Where x came from and how it was chosen is something we don't know.
  • Mathematical Conundrum or Not? Number Six

    I changed the code a bit to come up with another visual demonstration. I changed the two.envelopes function to just output A and then copied it to another function called two.envelopes.s which outputs B.

    What this simulates is if you never switch then you walking away with A and if you always switch then you walk away with B. I used a normal distribution for this example but honestly you can do the same thing for any distribution since the content of A and B are determined by the same chance event.

    The point of this demonstration is to show that the possible distribution of A is the same as the possible distribution of B so I have included some graphs that can be visually compared, and I use a Kolmogorov-Smirnov Tests, also known as the K-S test. This is a non-parametric test, and if you want the details on how it works just Google it, the concept is actually really simple.

    The K-S test compares two distributions to see if they match.

    The hypotheses works like this: Let F(x) and S(x) designate some unknown distribution functions of the X's and Y's respectively.

    Then our following two-sided null hypothesis is: F(x) = S(x) for all of x
    Then our alternative hypothesis is: F(x) does not equal S(x) for at least one value of x

    If you have never seen a classical statistical hypotheses test, the short and sweet of it, is if we get a low p-value we consider this evidence against the null hypothesis. The lower the p-value the greater the evidence. P-values range from 0 to 1. They are the probability of a ratio as extreme or more extreme than the observed given the null is true. Note they are not evidence for the null, failing to reject does not prove a null. The null is just that annoying guy that always demands you prove everything you say, but it is the alternative hypothesis that we are really testing for.


    Here is the code:

    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))
    }
    #sets the value for B based on: if A = x then B = 2x or if A = 2x then B = x
    g <- replicate(10000, two.envelopes())
    
    
    two.envelopes.s <- 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(B))
    }
    #sets the value for B based on: if A = x then B = 2x or if A = 2x then B = x
    g.s <- replicate(10000, two.envelopes())
    
    library(ggplot2)
    plot(g)
    plot(g.s)
    ggplot() + aes(g)+ geom_histogram(binwidth=10, colour="black", fill="white")
    
    ggplot() + aes(g.s)+ geom_histogram(binwidth=10, colour="black", fill="white")
    
    ks.test(g, g.s)
    
    #K-S test results
    
    p-value will be approximate in the presence of ties
    	Two-sample Kolmogorov-Smirnov test
    
    data:  g and g.s
    D = 0.0077, p-value = 0.9283
    alternative hypothesis: two-sided
    
    

    So we see with a D test statistics of 0.0077 and a 0.92 p-value we don't have strong enough evidence to support the alternative hypothesis that the two distributions are reasonably different.

    Of course this was an expected outcome and would remain true no matter how X was selected, as once X is selected its distribution in the envelopes is now something separate which depends on how the envelopes themselves are selected.

    If you don't like the K-S test here are some plots that allow you to view the similarities:

    There are scatter plots of each distribution and histograms of each. They will look very similar.

    Scatter Plots:

    https://ibb.co/ksr0P8

    https://ibb.co/bW6gxT

    Histograms:

    https://ibb.co/c9w3Bo

    https://ibb.co/h30248
  • 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.