/* Sleeping beauty problem in Picat. From https://medium.com/@theo.seeds/why-probability-isnt-real-df50b72a073e """ There’s a probability paradox called the "Sleeping Beauty Paradox". It seems simple at first, but philosophers and statisticians still haven’t figured it out. Here’s how it goes. An experimenter flips a coin on Sunday. Then, he puts his experiment subject, Sleeping Beauty, to sleep. When Sleeping Beauty wakes up, she won’t remember if the coin was heads or tails, and she won't remember if she’s been woken up before. If the coin’s heads, then the scientist wakes up Sleeping Beauty on Monday. If the coin’s tails, then the scientist wakes up Sleeping Beauty on Monday, puts her back to sleep, and then wakes her up again on Tuesday. So, suppose you’re Sleeping Beauty, and you wake up. You have no idea how the coin flip went and you have no idea what day it is. What’s the probability that the coin came up heads? The paradox There are two ways of looking at this problem. They both make sense when you explain them. They both seem equally valid. And they both give you completely different answers. One way of looking at the problem is looking at the coin flip. The coin had a 50/50 chance of being heads. And you’re gonna wake up either way — the fact that you’re awake now gives you no new information about the coin flip. So the coin is still 50% likely to have come up heads. Another way of looking at the problem is by looking at the fact you’ve woken up. Suppose you ran this experiment 100 times. Sleeping Beauty would wake up 100 times in a world where the coin was heads, and 200 times in a world where the coin was tails. So if you’re Sleeping Beauty and you’re waking up, there’s only a 1/3 probability that the coin was heads. Obviously, the probability can’t be 1/2 and 1/3. It’s a paradox. So what the hell’s going on? """ From https://en.wikipedia.org/wiki/Sleeping_Beauty_problem """ This has become the canonical form of the problem: Sleeping Beauty volunteers to undergo the following experiment and is told all of the following details: On Sunday she will be put to sleep. Once or twice, during the experiment, Sleeping Beauty will be awakened, interviewed, and put back to sleep with an amnesia-inducing drug that makes her forget that awakening. A fair coin will be tossed to determine which experimental procedure to undertake: - If the coin comes up heads, Sleeping Beauty will be awakened and interviewed on Monday only. - If the coin comes up tails, she will be awakened and interviewed on Monday and Tuesday. In either case, she will be awakened on Wednesday without interview and the experiment ends. Any time Sleeping Beauty is awakened and interviewed she will not be able to tell which day it is or whether she has been awakened before. During the interview Sleeping Beauty is asked: "What is your credence now for the proposition that the coin landed heads?" """ As mentioned in both these texts, there is two different approaches with different answers on the probability of head: - 1/2 - 1/3 This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import ppl_distributions, ppl_utils, ppl_common_utils. import util. % import ordset. main => go. /* Here we show two different approaches of modelling this problem of the probability of heads: either 1/2 or 1/3. var : sleeping beauty wakeups Probabilities: tails: 0.6663110162710056 heads: 0.3336889837289944 mean = [] var : p Probabilities: true: 0.5004000000000000 false: 0.4996000000000000 mean = 0.5004 */ go ?=> reset_store, run_model(20_000,$model,[show_probs_trunc,mean]), nl, nl. go => true. model() => Coin = categorical([1/2,1/2],[heads,tails]), SB = new_list(2), % The Sleeping Beauty if Coin = heads then SB[1] := wake_up, add("sleeping beauty wakeups",heads), % 1/3 solution else SB[1] := wake_up_and_sleep, SB[2] := wake_up, add("sleeping beauty wakeups",tails), add("sleeping beauty wakeups",tails), end, % 1/2 solution: % I.e. monday was a wake up but tuesday was not P = check( (SB[1] == wake_up ; SB[2] != wake_up)), add("p",P).