Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
20
Task/Sleeping-Beauty-problem/Nim/sleeping-beauty-problem.nim
Normal file
20
Task/Sleeping-Beauty-problem/Nim/sleeping-beauty-problem.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import random
|
||||
|
||||
const N = 1_000_000
|
||||
|
||||
type Side {.pure.} = enum Heads, Tails
|
||||
|
||||
const Sides = [Heads, Tails]
|
||||
|
||||
randomize()
|
||||
var onHeads, wakenings = 0
|
||||
for _ in 1..N:
|
||||
let side = sample(Sides)
|
||||
inc wakenings
|
||||
if side == Heads:
|
||||
inc onHeads
|
||||
else:
|
||||
inc wakenings
|
||||
|
||||
echo "Wakenings over ", N, " experiments: ", wakenings
|
||||
echo "Sleeping Beauty should estimate a credence of: ", onHeads / wakenings
|
||||
Loading…
Add table
Add a link
Reference in a new issue