vector-random-0.1: Generate vectors filled with high quality pseudorandom numbers

Data.Vector.Random.Mersenne

Description

 

Synopsis

Documentation

random :: (MTRandom a, Vector v a) => MTGen -> Int -> IO (v a)Source

Return a random vector of length n, filled with random elements of type a generated by the mersenne-twister.

E.g. to compute the sum of 100 million random Double values in a vector:

 import qualified Data.Vector.Unboxed as U
 import System.Random.Mersenne
 import qualified Data.Vector.Random.Mersenne as G
 
 main = do
     g <- newMTGen Nothing
     a <- G.random g 10000000 :: IO (U.Vector Double) -- 100 M
     print (U.sum a)