jeudi 23 avril 2015

Haskell gsl-random - how to specify RNGType?

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.




Aucun commentaire:

Enregistrer un commentaire