đŸ’Ÿ Archived View for idiomdrottning.org â€ș sleeping-beauty captured on 2024-08-25 at 01:00:25. Gemini links have been rewritten to link to archived content

View Raw

More Information

âŹ…ïž Previous capture (2023-01-29)

-=-=-=-=-=-=-

Running the Sleeping Beauty Experiment

In a middle-school math textbook I read about the Monty Hall problem and while it fascinated me, I thought that the explanation they gave made sense. In senior high I got into a lot of arguments and I ended up having to try to write some sort of BASIC script to try to show that it was true. Years later, reading about how vos Savant was treated (at around the same time), I was like “Yep! That tracks!”

I went through life cocky af thinking I was so g-d clever.

But for the Sleeping Beauty problem, which I first heard about five years ago, the shoe was suddenly on the other foot. I just couldn’t believe that the halfer position wasn’t true. I also thought that the problem was particularly frightening, philosophically, because of what it says about how, hmm, pointless our subjective estimations of probability might be.

So I decided to actually run the experiment! All of this was about five years ago but I found this old code on my drive and thought it might be fun to post on this blog, too. Ported to Chicken 5.

Now, I’ve made one change to the original problem because I don’t understand Bayesian probability and El’s the only one besides my dad who’s ever said “I love you Creedence”. That’s right folks! You’ve stumbled into the realm of an Dunning-Kruger–level armchair philosopher!

In my version, instead of asking “What’s your credence that the coin came up heads?” the question is instead “What do you think the coin has landed on?”

Also instead of using anesthesia I’m using the life-changing magic of computer programs.

Subject: Myself

First, I chose to go under myself. It surely isn’t fair to subject Sleeping Beauty to this when I’m not willing to experiment on myself.

The sleeper can’t have any memories of what has gone before. I can’t go “tails?” “correct!” “Ok, then next time it’s gonna be tails again, duh.” I need to actually forget everything.

To simulate that, I’m just gonna be subjected to a bunch of random awakenings.

(import (chicken random)  (srfi 1))

(define (flip)
  (list-ref '(heads tails) (pseudo-random-integer 2)))

(define (calendar)
  (list-ref '(monday tuesday) (pseudo-random-integer 2)))

(define (ask coin day loop)
  (print "What do you think the coin has landed on?")
  (let ((guess (read)))
    (print "You guessed " guess ". The answer was "
       coin ". You were "
       (if (eq? coin guess) 'correct 'incorrect) ".")
    )
  (loop (flip) (calendar)))

(let loop ((coin (flip)) (day (calendar)))
  (if (eq? coin 'heads)
      (if (eq? day 'monday)
      (ask coin day loop)
      (loop (flip) (calendar))) ; ← heads on a tuesday. let me sleep
      (if (eq? day 'tuesday)
      (ask coin day loop)
      (ask coin day loop))))

The simulation flips the coin randomly and it flips the calendar randomly. It just keeps doing that over and over and over again.

If it’s heads on a Tuesday the experimenters keep me in the cold land called coma. Otherwise they wake me up and asks me, I type in my reply and they reveal if I happened to be right that time. Here are some examples of this running but it’s different every time since it’s flipping random.

What do you think the coin has landed on?

tails

You guessed tails. The answer was tails. You were correct.

What do you think the coin has landed on?

tails

You guessed tails. The answer was tails. You were correct.

What do you think the coin has landed on?

tails

You guessed tails. The answer was tails. You were correct.

What do you think the coin has landed on?

tails

You guessed tails. The answer was tails. You were correct.

What do you think the coin has landed on?

tails

You guessed tails. The answer was heads. You were incorrect.

What do you think the coin has landed on?

tails

You guessed tails. The answer was tails. You were correct.

What do you think the coin has landed on?

tails

You guessed tails. The answer was heads. You were incorrect.

What do you think the coin has landed on?

heads

You guessed heads. The answer was heads. You were correct.

What do you think the coin has landed on?

heads

You guessed heads. The answer was tails. You were incorrect.

What do you think the coin has landed on?

heads

You guessed heads. The answer was tails. You were incorrect.

What do you think the coin has landed on?

heads

You guessed heads. The answer was heads. You were correct.

What do you think the coin has landed on?

heads

You guessed heads. The answer was tails. You were incorrect.

etc etc until I terminate the loop with C-c.

CS nerds can see that the final loop part of the above code can be refactored to

(let loop ((coin (flip)) (day (calendar)))
  (if (and (eq? coin 'heads)
       (eq? day 'tuesday))
      (loop (flip) (calendar)) ; ← heads on a tuesday. let me sleep
      (ask coin day loop)))

That’s a briefer version but has the same probabilites. Upon making that version, my halfer position started to tremble a bit. Executing it works the same as the above.

Subject: the Two Obstinate Beauties

It’s tedious to keep track of my own correct guesses and how often I’m right or wrong and from there try to estimate some kind of reasonable credence. And I had suffered enough. It was time to bring in some other subjects. Bots! I could have one bot that always guessed heads, and one that always guessed tails, and run the experiment hundreds, even millions of times and just tally up how often they were right.

(let heads-guessing-loop
    ((coin (pseudo-random-integer 2))
     (day (pseudo-random-integer 2))
     (guesses '()) (times 100))
  (if (zero? times)
      (reduce + 0 guesses)
      (if (zero? (+ coin day))
      (heads-guessing-loop
       (pseudo-random-integer 2)
       (pseudo-random-integer 2)
       guesses times) ; ← heads on a tuesday. let them sleep
      (heads-guessing-loop
       (pseudo-random-integer 2)
       (pseudo-random-integer 2)
       (cons (- 1 coin) guesses) (sub1 times)))))

(let tails-guessing-loop
    ((coin (pseudo-random-integer 2))
     (day (pseudo-random-integer 2))
     (guesses '()) (times 100))
  (if (zero? times)
      (reduce + 0 guesses)
      (if (zero? (+ coin day))
      (tails-guessing-loop
       (pseudo-random-integer 2)
       (pseudo-random-integer 2)
       guesses times) ; ← heads on a tuesday. let them sleep
      (tails-guessing-loop
       (pseudo-random-integer 2)
       (pseudo-random-integer 2)
       (cons coin guesses) (sub1 times)))))

The heads-guessing-loop ended up being right ⅓ of the time and the tails-guessing-loop ended up being right ⅔ of the time.

the Monty Hall problem

the Sleeping Beauty problem

Chicken 5

Bayesian probability

I love you Creedence