[Haskell-cafe] What's the best seed for random API ?

z_axis z_axis at 163.com
Thu Jan 6 01:21:34 CET 2011


picoSec :: IO Integer
picoSec = do
    t <- ctPicosec `liftM` (getClockTime >>= toCalendarTime)
    return t

rollDice ::  Int -> IO Int
rollDice n = do
    ps <- picoSec
    return $ (take 1 $ randomRs (1,n) $ mkStdGen $ fromInteger ps) !! 0

The above code uses `ctPicosec` as seed. Is it better to use the output of
/dev/urandom as seed ?

Sincerely!

-----
e^(π.i) + 1 = 0
-- 
View this message in context: http://haskell.1045720.n5.nabble.com/What-s-the-best-seed-for-random-API-tp3329807p3329807.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list