boltzmann-samplers-0.1.1.0: Uniform random generators

Safe HaskellNone
LanguageHaskell2010

Boltzmann.Species

Description

Applicative interface to define recursive structures and derive Boltzmann samplers.

Given the recursive structure of the types, and how to combine generators, the library takes care of computing the oracles and setting the right distributions.

Synopsis

Documentation

class Embed f m where #

Minimal complete definition

emap, embed

Methods

emap :: (m a -> m b) -> f a -> f b #

embed :: m a -> f a #

A natural transformation between f and m?

Instances
Embed f m => Embed (Pointiful f) m # 
Instance details

Defined in Boltzmann.Species

Methods

emap :: (m a -> m b) -> Pointiful f a -> Pointiful f b #

embed :: m a -> Pointiful f a #

MonadRandomLike m => Embed (Weighted m) m # 
Instance details

Defined in Boltzmann.Species

Methods

emap :: (m a -> m b) -> Weighted m a -> Weighted m b #

embed :: m a -> Weighted m a #

Num r => Embed (ConstModule r) m # 
Instance details

Defined in Boltzmann.Species

Methods

emap :: (m a -> m b) -> ConstModule r a -> ConstModule r b #

embed :: m a -> ConstModule r a #

class (Alternative f, Num (Scalar f)) => Module f where #

Applicative defines a product, Alternative defines an addition, with scalar multiplication we get a module.

This typeclass allows to directly tweak weights in the oracle by chosen factors.

Associated Types

type Scalar f :: * #

Methods

scalar :: Scalar f -> f () #

Scalar embedding.

(<.>) :: Scalar f -> f a -> f a infixr 3 #

Scalar multiplication.

Instances
Module f => Module (Pointiful f) # 
Instance details

Defined in Boltzmann.Species

Associated Types

type Scalar (Pointiful f) :: * #

Methods

scalar :: Scalar (Pointiful f) -> Pointiful f () #

(<.>) :: Scalar (Pointiful f) -> Pointiful f a -> Pointiful f a #

MonadRandomLike m => Module (Weighted m) # 
Instance details

Defined in Boltzmann.Species

Associated Types

type Scalar (Weighted m) :: * #

Methods

scalar :: Scalar (Weighted m) -> Weighted m () #

(<.>) :: Scalar (Weighted m) -> Weighted m a -> Weighted m a #

Num r => Module (ConstModule r) # 
Instance details

Defined in Boltzmann.Species

Associated Types

type Scalar (ConstModule r) :: * #

type Endo a = a -> a #

data System f a c #

Constructors

System 

Fields

Instances
Functor (System f a) # 
Instance details

Defined in Boltzmann.Species

Methods

fmap :: (a0 -> b) -> System f a a0 -> System f a b #

(<$) :: a0 -> System f a b -> System f a a0 #

sys :: System f a c -> f () -> Vector (f a) -> Vector (f a) #

newtype ConstModule r a #

Constructors

ConstModule 

Fields

Instances
Functor (ConstModule r) # 
Instance details

Defined in Boltzmann.Species

Methods

fmap :: (a -> b) -> ConstModule r a -> ConstModule r b #

(<$) :: a -> ConstModule r b -> ConstModule r a #

Num r => Applicative (ConstModule r) # 
Instance details

Defined in Boltzmann.Species

Methods

pure :: a -> ConstModule r a #

(<*>) :: ConstModule r (a -> b) -> ConstModule r a -> ConstModule r b #

liftA2 :: (a -> b -> c) -> ConstModule r a -> ConstModule r b -> ConstModule r c #

(*>) :: ConstModule r a -> ConstModule r b -> ConstModule r b #

(<*) :: ConstModule r a -> ConstModule r b -> ConstModule r a #

Num r => Alternative (ConstModule r) # 
Instance details

Defined in Boltzmann.Species

Methods

empty :: ConstModule r a #

(<|>) :: ConstModule r a -> ConstModule r a -> ConstModule r a #

some :: ConstModule r a -> ConstModule r [a] #

many :: ConstModule r a -> ConstModule r [a] #

Num r => Module (ConstModule r) # 
Instance details

Defined in Boltzmann.Species

Associated Types

type Scalar (ConstModule r) :: * #

Num r => Embed (ConstModule r) m # 
Instance details

Defined in Boltzmann.Species

Methods

emap :: (m a -> m b) -> ConstModule r a -> ConstModule r b #

embed :: m a -> ConstModule r a #

type Scalar (ConstModule r) # 
Instance details

Defined in Boltzmann.Species

type Scalar (ConstModule r) = r

solve :: forall b c. (forall a. Num a => System (ConstModule a) b c) -> Double -> Maybe (Vector Double) #

sizedGenerator #

Arguments

:: MonadRandomLike m 
=> (forall f. (Module f, Embed f m) => System (Pointiful f) b c) 
-> Int

Index of type

-> Int

Points

-> Maybe Double

Expected size (or singular sampler)

-> m b 

solveSized #

Arguments

:: (forall a. Num a => System (Pointiful (ConstModule a)) b c) 
-> Int

Index of type

-> Int

Points

-> Maybe Double

Expected size (or singular sampler)

-> (Double, Vector Double) 

newtype Weighted m a #

Constructors

Weighted [(Double, m a)] 
Instances
Functor m => Functor (Weighted m) # 
Instance details

Defined in Boltzmann.Species

Methods

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

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

MonadRandomLike m => Applicative (Weighted m) # 
Instance details

Defined in Boltzmann.Species

Methods

pure :: a -> Weighted m a #

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

liftA2 :: (a -> b -> c) -> Weighted m a -> Weighted m b -> Weighted m c #

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

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

MonadRandomLike m => Alternative (Weighted m) # 
Instance details

Defined in Boltzmann.Species

Methods

empty :: Weighted m a #

(<|>) :: Weighted m a -> Weighted m a -> Weighted m a #

some :: Weighted m a -> Weighted m [a] #

many :: Weighted m a -> Weighted m [a] #

MonadRandomLike m => Module (Weighted m) # 
Instance details

Defined in Boltzmann.Species

Associated Types

type Scalar (Weighted m) :: * #

Methods

scalar :: Scalar (Weighted m) -> Weighted m () #

(<.>) :: Scalar (Weighted m) -> Weighted m a -> Weighted m a #

MonadRandomLike m => Embed (Weighted m) m # 
Instance details

Defined in Boltzmann.Species

Methods

emap :: (m a -> m b) -> Weighted m a -> Weighted m b #

embed :: m a -> Weighted m a #

type Scalar (Weighted m) # 
Instance details

Defined in Boltzmann.Species

weighted :: Double -> m a -> Weighted m a #

sfix :: MonadRandomLike m => System (Weighted m) b c -> Double -> Vector Double -> (Vector (m b), c) #

data Pointiful f a #

Constructors

Pointiful [f a] 
Zero (f a) 
Instances
Functor f => Functor (Pointiful f) # 
Instance details

Defined in Boltzmann.Species

Methods

fmap :: (a -> b) -> Pointiful f a -> Pointiful f b #

(<$) :: a -> Pointiful f b -> Pointiful f a #

Module f => Applicative (Pointiful f) # 
Instance details

Defined in Boltzmann.Species

Methods

pure :: a -> Pointiful f a #

(<*>) :: Pointiful f (a -> b) -> Pointiful f a -> Pointiful f b #

liftA2 :: (a -> b -> c) -> Pointiful f a -> Pointiful f b -> Pointiful f c #

(*>) :: Pointiful f a -> Pointiful f b -> Pointiful f b #

(<*) :: Pointiful f a -> Pointiful f b -> Pointiful f a #

Module f => Alternative (Pointiful f) # 
Instance details

Defined in Boltzmann.Species

Methods

empty :: Pointiful f a #

(<|>) :: Pointiful f a -> Pointiful f a -> Pointiful f a #

some :: Pointiful f a -> Pointiful f [a] #

many :: Pointiful f a -> Pointiful f [a] #

Module f => Module (Pointiful f) # 
Instance details

Defined in Boltzmann.Species

Associated Types

type Scalar (Pointiful f) :: * #

Methods

scalar :: Scalar (Pointiful f) -> Pointiful f () #

(<.>) :: Scalar (Pointiful f) -> Pointiful f a -> Pointiful f a #

Embed f m => Embed (Pointiful f) m # 
Instance details

Defined in Boltzmann.Species

Methods

emap :: (m a -> m b) -> Pointiful f a -> Pointiful f b #

embed :: m a -> Pointiful f a #

type Scalar (Pointiful f) # 
Instance details

Defined in Boltzmann.Species

type Scalar (Pointiful f) = Scalar f

unPointiful :: Alternative f => Pointiful f a -> [f a] #

point :: Module f => Int -> System (Pointiful f) b c -> System f b c #