Closed FintanH closed 4 years ago
I seem to be able to use MWC
import Data.Random
import Data.Random.Source.MWC
import Data.Vector (singleton)
main :: IO ()
main = do
x <- sum <$> mapM (\m -> (initialize (singleton m) >>= \s -> sampleFrom s StdNormal) :: IO Double) [1..10000]
print x
I did try
$(randomSource [d|
instance (PrimMonad m) => RandomSource (ReaderT TF.TFGen m) TF.TFGen where
getRandomWord64From = undefined
getRandomDoubleFrom = undefined
|])
which compiles but what should the undefined
be? mwc-random
provides uniform
so we can replace undefined
with uniform
and fmap wordToDouble . uniform
. Maybe you can write uniform
for tf-random
?
I am very grateful for your contribution but your proposal seems to be quite a big change that I need more time than I have at the moment to properly assess.
I'm trying to use sampleState but I would like to use a different seed to kick this off, TFGen.
I can't seem to do this because I'm constrained to use
StdGen
orPureMT
. I was wondering if it might be possible to utilise the fact that all these seeds are instances ofRandomGen
and that way we can define it as:that'll allow the functionality to be extended. I'll dig into the code to see if it's possible myself.