hsc3-0.20: Haskell SuperCollider
Safe HaskellSafe-Inferred
LanguageHaskell2010

Sound.Sc3.Common.Random

Description

Linear congruential generator and related utilities. Ordinarily use System.Random.

Synopsis

Documentation

lcg :: Num t => (t -> t) -> t -> t -> t -> t Source #

Linear congruential generator given modulo function for type.

See http://en.wikipedia.org/wiki/Linear_congruential_generator for possible parameters.

lcgWord64Knuth :: Word64 -> Word64 Source #

lcg 6364136223846793005 1442695040888963407, so in (0, 18446744073709551615)

take 5 (iterate lcgWord64Knuth 147092873413)
(maxBound :: Word64) == (2 ^ 64 - 1)

lcgInt32Glibc :: Int32 -> Int32 Source #

lcg 1103515245 12345, so in (-2147483648, 2147483647)

take 5 (iterate lcgInt32Glibc 873413)
(minBound :: Int32,maxBound :: Int32) == (-2147483648, 2147483647)

cpuTimeSeedWord64 :: IO Word64 Source #

Run getCPUTime and convert to Word64

cpuTimeSeedInt32 :: IO Int32 Source #

Run getCPUTime and convert to Int32

lcgWord64KnuthCpuTime :: IO [Word64] Source #

Iterate lcgWord64Knuth using cpuTimeSeedWord64.

word64ToUnitDouble :: Word64 -> Double Source #

Convert Word64 to Double in range (0, 1). Shifts input right 11 places (ie. discards 11 least significant bits) then divide by 2^53.

lcgDoubleKnuthCpuTime :: IO [Double] Source #

word64ToUnitDouble of lcgWord64KnuthCpuTime

x <- fmap (take 256) lcgDoubleKnuthCpuTime
Sound.Sc3.Plot.plot_p1_ln [x]