hakaru 0.1.1 → 0.1.2
raw patch · 3 files changed
+28/−32 lines, 3 filesdep ~base
Dependency ranges changed: base
Files
- LICENSE +0/−30
- Sampler.hs +26/−0
- hakaru.cabal +2/−2
LICENSE view
@@ -1,30 +0,0 @@-Copyright (c) 2014, The Hakaru Team--All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions are met:-- * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.-- * Redistributions in binary form must reproduce the above- copyright notice, this list of conditions and the following- disclaimer in the documentation and/or other materials provided- with the distribution.-- * Neither the name of The Hakaru Team nor the names of other- contributors may be used to endorse or promote products derived- from this software without specific prior written permission.--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Sampler.hs view
@@ -0,0 +1,26 @@+{-# LANGUAGE RankNTypes #-}+{-# OPTIONS -W #-}++module Sampler (Sampler, deterministic, sbind, smap) where++import Mixture (Mixture, mnull, empty, scale, point)+import RandomChoice (choose)+import System.Random (RandomGen)++-- Sampling procedures that produce one sample++type Sampler a = forall g. (RandomGen g) => g -> (Mixture a, g)++deterministic :: Mixture a -> Sampler a+deterministic m g = (m, g)++sbind :: Sampler a -> (a -> Sampler b) -> Sampler b+sbind s k g0 =+ case s g0 of { (m1, g1) ->+ if mnull m1 then (empty, g1) else+ case choose m1 g1 of { (a, v, g2) ->+ case k a g2 of { (m2, g) ->+ (scale v m2, g) } } }++smap :: (a -> b) -> Sampler a -> Sampler b+smap f s = sbind s (\a -> deterministic (point (f a) 1))
hakaru.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: hakaru-version: 0.1.1+version: 0.1.2 synopsis: A probabilistic programming embedded DSL description: Hakaru is an embedded DSL for performing probabilistic inference. It supports multiple inference backends. homepage: http://www.indiana.edu/~ppaml@@ -17,7 +17,7 @@ cabal-version: >=1.10 library- exposed-modules: Types, Visual, Language.Hakaru.Syntax, Mixture, Language.Hakaru.Symbolic, RandomChoice, Util.Extras, Util.Coda, Examples.Tests, Language.Hakaru.ImportanceSampler, Language.Hakaru.Metropolis+ exposed-modules: Sampler, Types, Visual, Language.Hakaru.Syntax, Mixture, Language.Hakaru.Symbolic, RandomChoice, Util.Extras, Util.Coda, Examples.Tests, Language.Hakaru.ImportanceSampler, Language.Hakaru.Metropolis -- other-modules: other-extensions: RankNTypes, BangPatterns, OverloadedStrings, TypeFamilies, ConstraintKinds, GADTs, FlexibleContexts, TypeOperators, DataKinds, NoMonomorphismRestriction, DeriveDataTypeable, ScopedTypeVariables, ExistentialQuantification, StandaloneDeriving build-depends: base >=4.6 && <4.7, aeson >=0.7 && <0.8, text >=1.1 && <1.2, bytestring >=0.10 && <0.11, pretty >=1.1 && <1.2, logfloat >=0.12 && <0.13, containers >=0.5 && <0.6, random >=1.0 && <1.1, math-functions >=0.1 && <0.2, vector >=0.10 && <0.11, cassava >=0.4 && <0.5, zlib >=0.5 && <0.6, statistics >=0.11 && <0.12, hmatrix >=0.16 && <0.17, parsec >=3.1 && <3.2