XenonStack
Probabilistic Programming: Models, Tools and Uses
J
K
N
O
R
X
Y
Z

XenonStack GlossaryProbabilistic Programming: Models, Tools and Uses

Key takeaway

  • Probabilistic programming lets you write models with random variables and infer unknowns automatically. See how it works, key languages and uses.

Probabilistic programming is a programming paradigm in which you declare a probabilistic model, using random variables for unknown quantities, and the system performs inference automatically. It lets you tell a generative story about your data instead of building a black box.

This page is for data and AI teams that must reason under uncertainty. It covers random variables, inference methods, common languages, applications and how to start.

What is probabilistic programming?

Wikipedia describes it as a programming paradigm based on the declarative specification of probabilistic models, with inference carried out automatically. The aim is to combine probabilistic modelling with general purpose programming. Languages in this paradigm are called probabilistic programming languages, or PPLs.

The PyMC overview puts it this way: probabilistic programming allows for automatic Bayesian inference on user defined probabilistic models.

What are random variables in a probabilistic program?

In an ordinary program a variable holds one value. In a probabilistic program, unknowns are random variables with prior distributions. PyMC explains that you assign a prior distribution to the unknown variables in the model, and that observed variables represent the likelihood of the data. Deterministic variables are fully fixed by their parents, while stochastic variables depend on them only in part.

Two column diagram. You write: random variables, priors, likelihood, generative story. The engine does: picks a method, fits to data, returns distributions, supports decisions.

The result is a generative story: the model states how the data could have been produced, instead of acting as a black box.

How does inference work?

You write the model and the engine infers the unknowns. PyMC describes two families. Gradient based Markov chain Monte Carlo sampling, such as the No U Turn Sampler, and variational inference, which the docs say can be more efficient than MCMC for some problems at the cost of generalisability.

Other languages use other methods. Wikipedia mentions Gibbs sampling in WinBUGS and importance sampling and exact inference in other systems.

Which probabilistic programming languages are common?

LanguageHow its own site or page describes it
StanSoftware for Bayesian data analysis, with an active community and a commitment to open source
PyMCSpecify models in Python; automatic Bayesian inference
PyroA universal probabilistic programming language in Python with PyTorch as its backend, aiming to unify modern deep learning and Bayesian modelling
Others listed on WikipediaTuring.jl, Infer.NET, NumPyro, Gen, Edward, WebPPL, ProbLog and more

See the Stan and Pyro sites for details.

How does probabilistic programming differ from standard machine learning?

QuestionProbabilistic programmingTypical black box model
What you writeA model of how the data arisesA function fitted to examples
UncertaintyPart of the output, as distributionsOften a single point estimate
Prior knowledgeEncoded as priorsUsually implicit in features or architecture
ExplanationThe model structure is readableHarder to inspect

This is a comparison of approaches in general, not a claim about any one tool.

Where is it applied?

Wikipedia lists predicting stock prices, recommending movies, diagnosing computers, detecting cyber intrusions and image detection, along with vision and robotics tasks, pharmaceutical and economics work, and Bayesian cognitive science. These are all settings where information is uncertain or incomplete.

How does probabilistic programming relate to AI agents?

An agent that acts on uncertain information benefits from knowing how uncertain it is. A probabilistic model can supply that estimate as a distribution, and a policy can then decide when the agent acts and when it asks a human. ElixirClaw, XenonStack's AI agents computing platform, is where such agents are built and run.

What should you do first?

  1. Pick one decision where uncertainty matters.
  2. Write down what you already know as priors.
  3. Build a small model in PyMC, Stan or Pyro.
  4. Check the model against held back data.
  5. Record which model version informed each decision.

To map one decision your agents make under uncertainty, and the data and policy it depends on, book a Context Workshop. See what happens in the workshop.

Frequently asked questions

What is probabilistic programming in simple terms?

It is a way of writing a model of uncertain data as a program, then letting the system work out the unknowns automatically.

What is a probabilistic programming language?

A language built so that you declare a probabilistic model and inference runs automatically. Stan, PyMC and Pyro are examples.

Is probabilistic programming the same as Bayesian statistics?

No. Bayesian statistics is the method. Probabilistic programming is the tooling that lets you write Bayesian models as code and run inference automatically.

What inference methods do these tools use?

PyMC describes gradient based MCMC sampling and variational inference. Other tools use methods such as Gibbs sampling.

Can it be combined with deep learning?

Yes. Pyro describes itself as aiming to unify modern deep learning and Bayesian modelling, with PyTorch as its backend.