Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,21 @@
|
|||
import Data.Monoid (Sum(..))
|
||||
import System.Random (randomIO)
|
||||
import Control.Monad (replicateM)
|
||||
import Data.Bool (bool)
|
||||
|
||||
data Toss = Heads | Tails deriving Show
|
||||
|
||||
anExperiment toss =
|
||||
moreWakenings <>
|
||||
case toss of
|
||||
Heads -> headsOnWaking
|
||||
Tails -> moreWakenings
|
||||
where
|
||||
moreWakenings = (1,0)
|
||||
headsOnWaking = (0,1)
|
||||
|
||||
main = do
|
||||
tosses <- map (bool Heads Tails) <$> replicateM 1000000 randomIO
|
||||
let (Sum w, Sum h) = foldMap anExperiment tosses
|
||||
let ratio = fromIntegral h / fromIntegral w
|
||||
putStrLn $ "Ratio: " ++ show ratio
|
||||
Loading…
Add table
Add a link
Reference in a new issue