public
Created

  • Download Gist
GamblerHeaven.hs
Haskell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import Numeric.Probability.Distribution(T,uniform,decons,norm)
import Data.Maybe(fromJust)
 
step :: T Rational Integer -> T Rational Integer
step x = norm $ do
cash <- x
if (cash == 0) then
return 0
else do
f <- uniform [flip (-) 1, (*3)]
return (f cash)
result :: [T Rational Integer]
result = iterate step (return 1)
 
p :: [Rational]
p = map (fromJust . lookup 0 . decons) (tail result)
 
main =
mapM_ print $ (map fromRational p :: [Double])

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.