0

I'm trying to get the GSL bindings to distribution samplers working in haskell using gsl-random. I know there's random-fu as a higher-level option, but I'm finding random-fu is too slow for my purposes.

Say I want to sample from a beta distribution. The type specification based on the Hackage documentation is:

   getBeta :: RNG -> Double -> Double -> IO Double

I need an RNG object, this comes from the MkRNG

   newRNG :: RNGType -> IO RNG

How do I specify an RNGType?

λ> :i RNGType
newtype RNGType
  = gsl-random-0.5.0:GSL.Random.Gen.Internal.MkRNGType (GHC.Ptr.Ptr
                                                          ())
    -- Defined in ‘gsl-random-0.5.0:GSL.Random.Gen.Internal’

This is where I'm stuck. I don't understand how to instantiate an RNGType object based on this.

daj
  • 6,962
  • 9
  • 45
  • 79

1 Answers1

2

You have to use the functions mt19937 and rngType from the GSL.Random.Gen module to build a RNGType, since the implementation of RNGType is internal to this library.

bheklilr
  • 53,530
  • 6
  • 107
  • 163