Skip to content

stuhlmueller/cosh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cosh

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.

Installation

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.

  1. Install scheme-tools:

    1. Clone the scheme-tools repository using git clone git://github.com/stuhlmueller/scheme-tools.git.

    2. Add the scheme-tools directory to your $VICARE_LIBRARY_PATH.

      To add a directory to your $VICARE_LIBRARY_PATH, change into the directory and type echo -e "\nexport VICARE_LIBRARY_PATH=`pwd`:$VICARE_LIBRARY_PATH" >> /.bashrc. Replace /.bashrc with the location of your shell config file.

    3. Add the scheme-tools/bin directory to your $PATH.

      To add a directory to your $PATH, cd into the directory and type echo -e "\nexport PATH=`pwd`:$PATH" >> ~/.bashrc.

  2. Install scheme-transforms:

    1. Clone the repository using git clone git://github.com/stuhlmueller/scheme-transforms.git.

    2. Add the scheme-transforms directory to your $VICARE_LIBRARY_PATH (see above).

  3. Install cosh:

    1. Clone the repository using git clone git://github.com/stuhlmueller/cosh.git.

    2. Add the cosh directory to your $VICARE_LIBRARY_PATH (see above).

    3. Add the cosh/bin directory to your $PATH (see above).

  4. Reload your shell config file, e.g., via source ~/.bashrc.

Usage

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.

Options

$ 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

About

Dynamic programming inference by continuation hashing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published