Cosh is an experimental Church implementation that uses dynamic programming based on hashing factored continuations.
Cosh is deprecated. If you are looking to write probabilistic programs in Scheme syntax, webchurch is your best bet. You can use it online at probmods.org, or on your computer via nodejs. If you are not tied to Scheme syntax, I recommend webppl, our most recent probabilistic programming language. webppl is significantly faster than previous implementations, and additionally supports particle filtering and best-first enumeration inference strategies.
This installation assumes that you have git and a R6RS Scheme installed. The instructions on the Church wiki describe how to install Vicare Scheme with foreign function interface enabled.
-
Install scheme-tools:
-
Clone the scheme-tools repository using
git clone git://github.com/stuhlmueller/scheme-tools.git
. -
Add the scheme-tools directory to your
$VICARE_LIBRARY_PATH
.To add a directory to your
$VICARE_LIBRARY_PATH
, change into the directory and typeecho -e "\nexport VICARE_LIBRARY_PATH=`pwd`:$VICARE_LIBRARY_PATH" >>
. Replace/.bashrc/.bashrc
with the location of your shell config file. -
Add the scheme-tools/bin directory to your
$PATH
.To add a directory to your
$PATH
,cd
into the directory and typeecho -e "\nexport PATH=`pwd`:$PATH" >> ~/.bashrc
.
-
-
Install scheme-transforms:
-
Clone the repository using
git clone git://github.com/stuhlmueller/scheme-transforms.git
. -
Add the scheme-transforms directory to your
$VICARE_LIBRARY_PATH
(see above).
-
-
Install cosh:
-
Clone the repository using
git clone git://github.com/stuhlmueller/cosh.git
. -
Add the cosh directory to your
$VICARE_LIBRARY_PATH
(see above). -
Add the cosh/bin directory to your
$PATH
(see above).
-
-
Reload your shell config file, e.g., via
source ~/.bashrc
.
Create a file called myprogram.church with the following content:
(rejection-query
(define x (flip))
(define y (flip))
(list x y)
(or x y))
Then, on the command line, type:
cosh myprogram.church
You should see the following output:
(#f #t): 0.3333333333333332 (-1.09861228866811)
(#t #f): 0.3333333333333332 (-1.09861228866811)
(#t #t): 0.3333333333333332 (-1.09861228866811)
This shows the probability (and log probability) of each possible program return value.
$ cosh --help
Usage: cosh <file> [options]
Options:
-h, --help show this help message and exit
-d, --debug run all scheme commands in debug mode
-k, --keep do not delete compiled file
-l LIMIT, --limit=LIMIT
restrict graph size
-v, --verbose display all executed commands
-t, --time record runtime