flat-mcmc

Painless, efficient, general-purpose sampling from continuous distributions.
Log | Files | Refs | README | LICENSE

commit 6a927b21f6ff6327226b2faee53d9e21dc88e52b
parent 1332db977dc1c0d6205f2f8903d26929a4454b4a
Author: Jared Tobin <jared@jtobin.ca>
Date:   Sun,  3 Apr 2016 20:36:45 +0700

Remove old examples. [ci skip]

Diffstat:
M.gitignore | 1+
DExamples/code/BNN_Flat.hs | 37-------------------------------------
DExamples/code/Himmelblau_Flat.hs | 40----------------------------------------
DExamples/code/Rosenbrock_Flat.hs | 37-------------------------------------
DExamples/code/SPDE_Flat.hs | 48------------------------------------------------
DExamples/code/build_examples.sh | 25-------------------------
DExamples/demos/bnn.sh | 14--------------
DExamples/demos/himmelblau.sh | 15---------------
DExamples/demos/rosenbrock.sh | 14--------------
9 files changed, 1 insertion(+), 230 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -20,3 +20,4 @@ sandbox cabal.sandbox.config .stack-work debug +Examples diff --git a/Examples/code/BNN_Flat.hs b/Examples/code/BNN_Flat.hs @@ -1,37 +0,0 @@ -import System.IO -import System.Exit -import System.Environment -import System.Random.MWC -import Control.Monad -import Numeric.MCMC.Flat -import qualified Data.Vector as V - -target :: [Double] -> Double -target [x0, x1] = -0.5*(x0^2 * x1^2 + x0^2 + x1^2 - 8*x0 - 8*x1) -{-# INLINE target #-} - -main = do - args <- getArgs - when (args == []) $ do - putStrLn "(flat-mcmc) Bivariate non-normal density " - putStrLn "Usage: ./BNN_Flat <numSteps> <inits> " - putStrLn " " - putStrLn "numSteps : Number of Markov chain iterations to run." - putStrLn "inits : Filepath containing points at which to " - putStrLn " initialize the ensemble. " - exitSuccess - - inits <- readInits (args !! 1) - - let nepochs = read (head args) :: Int - opts = Options { _size = V.length inits - , _nEpochs = nepochs - , _burnIn = 0 - , _thinEvery = 1 - , _csize = 30 } - - initState = MarkovChain inits 0 - - g <- create - void $ runChain target opts initState g - diff --git a/Examples/code/Himmelblau_Flat.hs b/Examples/code/Himmelblau_Flat.hs @@ -1,40 +0,0 @@ -import System.IO -import System.Exit -import System.Environment -import System.Random.MWC -import Control.Monad -import Numeric.MCMC.Flat -import qualified Data.Vector as V - -target :: [Double] -> Double -target [x0, x1] = (-1)*((x0*x0 + x1 - 11)^2 + (x0 + x1*x1 - 7)^2) -{-# INLINE target #-} - -main = do - args <- getArgs - when (args == []) $ do - putStrLn "(flat-mcmc) Himmelblau density " - putStrLn "Usage: ./Himmelblau_Flat <numSteps> <burnIn> <inits> " - putStrLn " " - putStrLn "numSteps : Number of Markov chain iterations to run." - putStrLn "burnIn : Number of burn-in steps to perform. " - putStrLn "inits : Filepath containing points at which to " - putStrLn " initialize the ensemble. " - exitSuccess - - inits <- readInits (args !! 2) - - let nepochs = read (head args) :: Int - burnIn = read (args !! 1) :: Int - - opts = Options { _size = V.length inits - , _nEpochs = nepochs - , _burnIn = burnIn - , _thinEvery = 1 - , _csize = 30 } - - initState = MarkovChain inits 0 - - g <- create - void $ runChain target opts initState g - diff --git a/Examples/code/Rosenbrock_Flat.hs b/Examples/code/Rosenbrock_Flat.hs @@ -1,37 +0,0 @@ -import System.IO -import System.Exit -import System.Environment -import System.Random.MWC -import Control.Monad -import Numeric.MCMC.Flat -import qualified Data.Vector as V - -target :: [Double] -> Double -target [x0, x1] = (-1)*(5*(x1 - x0^2)^2 + 0.05*(1 - x0)^2) -target _ = error "explode" - -main = do - args <- getArgs - when (args == []) $ do - putStrLn "(flat-mcmc) Rosenbrock density " - putStrLn "Usage: ./Rosenbrock_Flat <numSteps> <inits> " - putStrLn " " - putStrLn "numSteps : Number of Markov chain iterations to run." - putStrLn "inits : Filepath containing points at which to " - putStrLn " initialize the ensemble. " - exitSuccess - - inits <- readInits (args !! 1) - - let nepochs = read (head args) :: Int - opts = Options { _size = V.length inits - , _nEpochs = nepochs - , _burnIn = 0 - , _thinEvery = 1 - , _csize = 30 } - - initState = MarkovChain inits 0 - - g <- create - void $ runChain target opts initState g - diff --git a/Examples/code/SPDE_Flat.hs b/Examples/code/SPDE_Flat.hs @@ -1,48 +0,0 @@ -import System.IO -import System.Exit -import System.Environment -import System.Random.MWC -import Control.Monad -import Numeric.MCMC.Flat -import qualified Data.Vector as V - -target :: [Double] -> Double -target xs = go 0 0 xs - where go t0 t1 [] = (-t0 / (2*h)) - (0.5*h*t1) - go t0 t1 (u:us:uss) = go (t0 + (us - u)^2) (t1 + v (us + u)) uss - h = 1 / fromIntegral (length xs) - v x = (1 - x^2)^2 -{-# INLINE target #-} - -main = do - args <- getArgs - when (args == []) $ do - putStrLn "(flat-mcmc) Stochastic partial differential equation " - putStrLn "Usage: ./SPDE_Flat <numSteps> <inits> <thinEvery> <burnIn> <granularity> " - putStrLn " " - putStrLn "numSteps : Number of Markov chain iterations to run." - putStrLn "inits : Filepath containing points at which to " - putStrLn " initialize the ensemble. " - putStrLn "thinEvery : Print every n^th iteration. " - putStrLn "burnIn : Number of burn-in steps. " - putStrLn "granularity : Parallel granularity (smaller is finer). " - exitSuccess - - inits <- readInits (args !! 1) - - let nepochs = read (head args) :: Int - thinEvery = read (args !! 2) :: Int - burnIn = read (args !! 3) :: Int - gran = read (args !! 4) :: Int - - opts = Options { _size = V.length inits - , _nEpochs = nepochs - , _burnIn = burnIn - , _thinEvery = thinEvery - , _csize = gran } - - initState = MarkovChain inits 0 - - g <- create - void $ runChain target opts initState g - diff --git a/Examples/code/build_examples.sh b/Examples/code/build_examples.sh @@ -1,25 +0,0 @@ -#!/bin/bash -EXAMPLES_DIR=/Users/jtobin/projects/flat-mcmc/Examples/code -DEST_DIR=/Users/jtobin/projects/flat-mcmc/Examples/demos -GHC_ARGS="-O2 +RTS -fllvm -threaded -rtsopts" - -cd $EXAMPLES_DIR - -# Compile examples -for file in *hs -do - ghc $file -O2 -fllvm -threaded -rtsopts -done - -# Strip the binaries and move to destination -BINS=$(ls *[^.hs]) - -for bin in $BINS -do - strip $bin - mv $bin $DEST_DIR -done - -# Clean up -rm *.hi *.o - diff --git a/Examples/demos/bnn.sh b/Examples/demos/bnn.sh @@ -1,14 +0,0 @@ -#!/bin/bash -DEST_DIR=../data/output - -# consider passing these args to the script -nepochs=1000 -inits=../data/input/inits-2d.dat - -NOW=$(date +"%Y-%m-%d-%H%M") - -./BNN_Flat $nepochs $inits \ - +RTS -N -qg -s \ - > $DEST_DIR/bnn_"$nepochs"_"$NOW".dat \ - 2> $DEST_DIR/bnn_"$nepochs"_"$NOW".rts - diff --git a/Examples/demos/himmelblau.sh b/Examples/demos/himmelblau.sh @@ -1,15 +0,0 @@ -#!/bin/bash -DEST_DIR=../data/output - -# consider passing these args to the script -nepochs=1000 -burnIn=200 -inits=../data/input/inits-2d.dat - -NOW=$(date +"%Y-%m-%d-%H%M") - -./Himmelblau_Flat $nepochs $burnIn $inits \ - +RTS -N -qg -s \ - > $DEST_DIR/himmelblau_"$nepochs"_"$NOW".dat \ - 2> $DEST_DIR/himmelblau_"$nepochs"_"$NOW".rts - diff --git a/Examples/demos/rosenbrock.sh b/Examples/demos/rosenbrock.sh @@ -1,14 +0,0 @@ -#!/bin/bash -DEST_DIR=../data/output - -# consider passing these args to the script -nepochs=1000 -inits=../data/input/inits-2d.dat - -NOW=$(date +"%Y-%m-%d-%H%M") - -./Rosenbrock_Flat $nepochs $inits \ - +RTS -N -qg -s \ - > $DEST_DIR/rosenbrock_"$nepochs"_"$NOW".dat \ - 2> $DEST_DIR/rosenbrock_"$nepochs"_"$NOW".rts -