Copyright | (c) Sentenai 2017 |
---|---|
License | BSD3 |
Maintainer | sam@sentenai.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
typeclass to remove extraneous mwc-random functions
- class Monad m => MonadMWCRandom m where
- type MonadMWCRandomIO m = (MonadIO m, MonadMWCRandom m)
- type MWCRand = MWCRandT Identity
- newtype MWCRandT m a = MWCRandT {
- getMWCRandT :: ReaderT GenIO m a
- runMWCRand :: MWCRand a -> GenIO -> a
- runMWCRandT :: MWCRandT m a -> GenIO -> m a
- type GenIO = Gen (PrimState IO)
- uniform :: (MonadIO m, MonadMWCRandom m, Variate a) => m a
- uniformR :: (MonadIO m, MonadMWCRandom m, Variate a) => (a, a) -> m a
- genContVar :: (MonadIO m, MonadMWCRandom m, ContGen d) => d -> m Double
- sampleFrom :: (MonadIO m, MonadMWCRandom m) => [Double] -> m (Int, [Double])
- class Variate a
- _uniform :: (PrimMonad m, Variate a) => Gen (PrimState m) -> m a
Documentation
class Monad m => MonadMWCRandom m where Source #
MonadMWCRandom for public use. FIXME: use with PrimState so that we can use ST
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. |
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 # | |
(Monoid w, MonadMWCRandom m) => MonadMWCRandom (WriterT w m) Source # | |
MonadMWCRandom m => MonadMWCRandom (ReaderT * s m) Source # | |
(MonadIO t, MonadMWCRandom t) => MonadMWCRandom (GymEnvironmentT s a t) Source # | |
(Monoid w, MonadMWCRandom m) => MonadMWCRandom (RWST r w s m) Source # | |
type MonadMWCRandomIO m = (MonadIO m, MonadMWCRandom m) Source #
A convenience type constraint with MonadMWCRandom and MonadIO.
a wrapper to share a generator without using reader
MWCRandT | |
|
MonadTrans MWCRandT Source # | |
Monad m => Monad (MWCRandT m) Source # | |
Functor m => Functor (MWCRandT m) Source # | |
Applicative m => Applicative (MWCRandT m) Source # | |
MonadIO m => MonadIO (MWCRandT m) Source # | |
MonadThrow m => MonadThrow (MWCRandT m) Source # | |
Monad m => MonadMWCRandom (MWCRandT m) Source # | instance declaration of MonadMWCRandom for MWCRandT |
Logger m => Logger (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 |
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
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
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.
Variate Bool | |
Variate Double | |
Variate Float | |
Variate Int | |
Variate Int8 | |
Variate Int16 | |
Variate Int32 | |
Variate Int64 | |
Variate Word | |
Variate Word8 | |
Variate Word16 | |
Variate Word32 | |
Variate Word64 | |
(Variate a, Variate b) => Variate (a, b) | |
(Variate a, Variate b, Variate c) => Variate (a, b, c) | |
(Variate a, Variate b, Variate c, Variate d) => Variate (a, b, c, d) | |