reinforce-0.0.0.1: Reinforcement learning in Haskell

Copyright(c) Sentenai 2017
LicenseBSD3
Maintainersam@sentenai.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Control.MonadMWCRandom

Contents

Description

typeclass to remove extraneous mwc-random functions

Synopsis

Documentation

class Monad m => MonadMWCRandom m where Source #

MonadMWCRandom for public use. FIXME: use with PrimState so that we can use ST

Minimal complete definition

getGen

Methods

getGen :: m GenIO Source #

Instances

MonadMWCRandom IO Source #

in the end, we can always use IO to get our generator, but we will create a new generator on each use.

Methods

getGen :: IO GenIO Source #

MonadMWCRandom Environment Source # 
MonadMWCRandom Environment Source # 
Monad m => MonadMWCRandom (MWCRandT m) Source #

instance declaration of MonadMWCRandom for MWCRandT

MonadMWCRandom m => MonadMWCRandom (StateT s m) Source # 

Methods

getGen :: StateT s m GenIO Source #

(Monoid w, MonadMWCRandom m) => MonadMWCRandom (WriterT w m) Source # 

Methods

getGen :: WriterT w m GenIO Source #

MonadMWCRandom m => MonadMWCRandom (ReaderT * s m) Source # 

Methods

getGen :: ReaderT * s m GenIO Source #

(MonadIO t, MonadMWCRandom t) => MonadMWCRandom (GymEnvironmentT s a t) Source # 
(Monoid w, MonadMWCRandom m) => MonadMWCRandom (RWST r w s m) Source # 

Methods

getGen :: RWST r w s m GenIO Source #

type MonadMWCRandomIO m = (MonadIO m, MonadMWCRandom m) Source #

A convenience type constraint with MonadMWCRandom and MonadIO.

type MWCRand = MWCRandT Identity Source #

simple type alias for transformer-less variant

newtype MWCRandT m a Source #

a wrapper to share a generator without using reader

Constructors

MWCRandT 

Fields

Instances

MonadTrans MWCRandT Source # 

Methods

lift :: Monad m => m a -> MWCRandT m a #

Monad m => Monad (MWCRandT m) Source # 

Methods

(>>=) :: MWCRandT m a -> (a -> MWCRandT m b) -> MWCRandT m b #

(>>) :: MWCRandT m a -> MWCRandT m b -> MWCRandT m b #

return :: a -> MWCRandT m a #

fail :: String -> MWCRandT m a #

Functor m => Functor (MWCRandT m) Source # 

Methods

fmap :: (a -> b) -> MWCRandT m a -> MWCRandT m b #

(<$) :: a -> MWCRandT m b -> MWCRandT m a #

Applicative m => Applicative (MWCRandT m) Source # 

Methods

pure :: a -> MWCRandT m a #

(<*>) :: MWCRandT m (a -> b) -> MWCRandT m a -> MWCRandT m b #

(*>) :: MWCRandT m a -> MWCRandT m b -> MWCRandT m b #

(<*) :: MWCRandT m a -> MWCRandT m b -> MWCRandT m a #

MonadIO m => MonadIO (MWCRandT m) Source # 

Methods

liftIO :: IO a -> MWCRandT m a #

MonadThrow m => MonadThrow (MWCRandT m) Source # 

Methods

throwM :: Exception e => e -> MWCRandT m a #

Monad m => MonadMWCRandom (MWCRandT m) Source #

instance declaration of MonadMWCRandom for MWCRandT

Logger m => Logger (MWCRandT m) Source # 

Methods

info :: Text -> MWCRandT m () Source #

info_ :: Text -> Text -> MWCRandT m () Source #

debug :: Text -> MWCRandT m () Source #

debug_ :: Text -> Text -> MWCRandT m () Source #

MonadEnv m s a r => MonadEnv (MWCRandT m) s a r Source #

An instance which allows for an environment to hold a reference to a shared MWC-random generator

Methods

reset :: MWCRandT m (Initial s) Source #

step :: a -> MWCRandT m (Obs r s) Source #

runMWCRand :: MWCRand a -> GenIO -> a Source #

run a transformerless MWC-random Monad

runMWCRandT :: MWCRandT m a -> GenIO -> m a Source #

unwrap MonadMWCRandom

re-exports from System.Random.MWC

type GenIO = Gen (PrimState IO) #

A shorter name for PRNG state in the IO monad.

wrappers for System.Random.MWC

uniform :: (MonadIO m, MonadMWCRandom m, Variate a) => m a Source #

uniform referencing MonadMWCRandom's generator

uniformR :: (MonadIO m, MonadMWCRandom m, Variate a) => (a, a) -> m a Source #

uniformR referencing MonadMWCRandom's generator

wrappers for Statistics.Distribution

genContVar :: (MonadIO m, MonadMWCRandom m, ContGen d) => d -> m Double Source #

genContVar referencing MonadMWCRandom's generator

extras

sampleFrom :: (MonadIO m, MonadMWCRandom m) => [Double] -> m (Int, [Double]) Source #

Sample a single index from a list of weights, converting the list into a distribution

class Variate a #

The class of types for which we can generate uniformly distributed random variates.

The uniform PRNG uses Marsaglia's MWC256 (also known as MWC8222) multiply-with-carry generator, which has a period of 2^8222 and fares well in tests of randomness. It is also extremely fast, between 2 and 3 times faster than the Mersenne Twister.

Note: Marsaglia's PRNG is not known to be cryptographically secure, so you should not use it for cryptographic operations.

Minimal complete definition

uniform, uniformR

Instances

Variate Bool 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Bool #

uniformR :: PrimMonad m => (Bool, Bool) -> Gen (PrimState m) -> m Bool #

Variate Double 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Double #

uniformR :: PrimMonad m => (Double, Double) -> Gen (PrimState m) -> m Double #

Variate Float 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Float #

uniformR :: PrimMonad m => (Float, Float) -> Gen (PrimState m) -> m Float #

Variate Int 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Int #

uniformR :: PrimMonad m => (Int, Int) -> Gen (PrimState m) -> m Int #

Variate Int8 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Int8 #

uniformR :: PrimMonad m => (Int8, Int8) -> Gen (PrimState m) -> m Int8 #

Variate Int16 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Int16 #

uniformR :: PrimMonad m => (Int16, Int16) -> Gen (PrimState m) -> m Int16 #

Variate Int32 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Int32 #

uniformR :: PrimMonad m => (Int32, Int32) -> Gen (PrimState m) -> m Int32 #

Variate Int64 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Int64 #

uniformR :: PrimMonad m => (Int64, Int64) -> Gen (PrimState m) -> m Int64 #

Variate Word 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Word #

uniformR :: PrimMonad m => (Word, Word) -> Gen (PrimState m) -> m Word #

Variate Word8 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Word8 #

uniformR :: PrimMonad m => (Word8, Word8) -> Gen (PrimState m) -> m Word8 #

Variate Word16 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Word16 #

uniformR :: PrimMonad m => (Word16, Word16) -> Gen (PrimState m) -> m Word16 #

Variate Word32 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Word32 #

uniformR :: PrimMonad m => (Word32, Word32) -> Gen (PrimState m) -> m Word32 #

Variate Word64 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m Word64 #

uniformR :: PrimMonad m => (Word64, Word64) -> Gen (PrimState m) -> m Word64 #

(Variate a, Variate b) => Variate (a, b) 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m (a, b) #

uniformR :: PrimMonad m => ((a, b), (a, b)) -> Gen (PrimState m) -> m (a, b) #

(Variate a, Variate b, Variate c) => Variate (a, b, c) 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m (a, b, c) #

uniformR :: PrimMonad m => ((a, b, c), (a, b, c)) -> Gen (PrimState m) -> m (a, b, c) #

(Variate a, Variate b, Variate c, Variate d) => Variate (a, b, c, d) 

Methods

uniform :: PrimMonad m => Gen (PrimState m) -> m (a, b, c, d) #

uniformR :: PrimMonad m => ((a, b, c, d), (a, b, c, d)) -> Gen (PrimState m) -> m (a, b, c, d) #

_uniform :: (PrimMonad m, Variate a) => Gen (PrimState m) -> m a Source #

a convenience helper to reference the underlying System.Random.MWC function