Skip to main content
QUICK REVIEW

[Paper Review] Design and Implementation of Probabilistic Programming Language Anglican

David Tolpin, Jan Willem van de Meent|arXiv (Cornell University)|Aug 18, 2016
Bayesian Modeling and Causal InferenceComputer Science15 references18 citations
TL;DR

Anglican is a probabilistic programming language implemented as a macro-extended dialect of Clojure, enabling seamless integration with JVM ecosystems. It uses a CPS-based evaluation model and functional abstractions to efficiently compile and execute probabilistic programs with support for multiple inference algorithms, achieving high performance and expressiveness while maintaining tight interoperability with general-purpose code.

ABSTRACT

Anglican is a probabilistic programming system designed to interoperate with Clojure and other JVM languages. We introduce the programming language Anglican, outline our design choices, and discuss in depth the implementation of the Anglican language and runtime, including macro-based compilation, extended CPS-based evaluation model, and functional representations for probabilistic paradigms, such as a distribution, a random process, and an inference algorithm. We show that a probabilistic functional language can be implemented efficiently and integrated tightly with a conventional functional language with only moderate computational overhead. We also demonstrate how advanced probabilistic modeling concepts are mapped naturally to the functional foundation.

Motivation & Objective

  • To design and implement a probabilistic programming language that integrates natively with general-purpose functional languages like Clojure.
  • To enable efficient execution of probabilistic programs through macro-based compilation and a CPS-based evaluation model.
  • To support multiple inference algorithms (e.g., Metropolis-Hastings, BBVB) within a unified, composable framework.
  • To maintain high performance and expressiveness while allowing full access to Clojure’s ecosystem for data I/O, preprocessing, and visualization.
  • To demonstrate that probabilistic functional programming can be both efficient and practical for real-world data science workflows.

Proposed method

  • Leverages Clojure’s macro system to extend syntax and alter operational semantics, enabling probabilistic constructs within a functional language.
  • Employs source-to-source compilation to transform Anglican code into Clojure, preserving functional abstractions and enabling runtime interpretation.
  • Uses a continuation-passing style (CPS) evaluation model to manage control flow and support non-deterministic execution across multiple inference runs.
  • Represents probabilistic concepts (distributions, random processes, inference algorithms) as first-class functional values for composability.
  • Supports inference via generic backends, including Lightweight Metropolis-Hastings and Black-Box Variational Bayes (BBVB), with configurable query interfaces.
  • Enables explicit naming of probabilistic forms (e.g., via `defm` and `sample` with identifiers) to improve interpretability of posterior distributions.

Experimental results

Research questions

  • RQ1How can a probabilistic programming language be efficiently implemented as an extension of a general-purpose functional language like Clojure?
  • RQ2What design patterns and compilation strategies enable high performance and seamless interoperability between probabilistic and deterministic code?
  • RQ3To what extent can functional abstractions (e.g., higher-order functions, closures) be used to represent and compose probabilistic models and inference algorithms?
  • RQ4How does the integration of multiple inference algorithms (e.g., MCMC and variational inference) affect usability and performance in practice?
  • RQ5Can a macro-based approach achieve both expressiveness and efficiency in a probabilistic language without sacrificing type safety or composability?

Key findings

  • Anglican achieves state-of-the-art computational efficiency among probabilistic programming systems, with only moderate overhead when integrated with Clojure.
  • The use of macro-based compilation and CPS-based evaluation enables efficient, composable execution of probabilistic programs with fine-grained control over inference.
  • Inference via Black-Box Variational Bayes (BBVB) successfully approximated posterior distributions, returning interpretable parameters such as mean and standard deviation for normal and Bernoulli distributions.
  • Explicit naming of probabilistic forms (e.g., `:arrival-time-same`, `:same-or-different`) significantly improved the interpretability of posterior results compared to auto-generated identifiers.
  • The integration of Anglican with Clojure allows full use of Clojure’s libraries for data processing, visualization, and statistical analysis, enabling end-to-end data science workflows.
  • The system demonstrates that probabilistic models can be specified concisely and modularly, while inference remains generic and interchangeable via a unified query interface.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.