Skip to content

Instantly share code, notes, and snippets.

@Mathnerd314
Created November 15, 2012 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mathnerd314/4076804 to your computer and use it in GitHub Desktop.
Save Mathnerd314/4076804 to your computer and use it in GitHub Desktop.
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])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment