Hakaru


Hakaru is a probabilistic programming language. A probabilistic programming language is a language specifically designed for manipulating probability distributions. These sorts of languages are great for machine learning and stochastic modeling.

Overview

This manual provides a guide for how to use Hakaru.

Introduction

What is Probabilistic Programming

Probabilistic programming systems allow us to write programs which describe probability distributions, and provide mechanisms to sample and condition the distributions they represent on data. In this page, we give a sense of the sorts of problems Hakaru is great at solving, and how you would describe them in Hakaru.

Installation

Learn how to install Hakaru

Quickstart

Get started with this quickstart page. Where we show how to sample and condition from a small Hakaru program.

Examples

Here we go through several more involved examples of the kinds of problems Hakaru is uniquely well-suited to solve.

In particular, we describe a model for Gaussian Mixture Models and using a form of Bayesian Naives Bayes as applied to document classification.

Language Guide

The language section provides an overview of the syntax of Hakaru as well as some of the primitives in the language.

Random Primitives

These are the built-in probability distributions.

Let and Bind

This is how we can give names to subexpressions and a draw from a probability distribution.

Conditionals

Hakaru supports a restricted if expression

Types and Coercions

Hakaru is a simply-typed language. This section describes the types available and functions for moving between them.

Functions

Defining and using functions

Datatypes and match

Hakaru supports a few built-in datatypes, and offers functionality for taking them apart and reconstructing them.

Arrays and loops

We offer special support for arrays, and for probability distributions over arrays. We also express loops that compute sums and products.

Transformations

Hakaru implements its inference algorithms predominately as program transformations. The following are the major ones our system provides.

Expect

Computing expectation of a measure

Disintegrate

A transformation which takes a joint distribution and produces a program representing the conditional distribution.

Simplify

Any Hakaru expression can be simplified, using the Maple computer-algebra system.

Metropolis Hastings

Automatically transform a measure into a transition kernel usable in a Metropolis Hastings algorithm.

Compiling to Haskell

Compiling to C

Internals

The internals section of the manual provides some insight into how Hakaru is implemented and offers guidance into how the system can be extended.

AST

ABT

Datums

Coercions

Transformations

Testing

Adding a Language Feature