News: Turing.jl is now Julia 1.0 compatible now! Be aware that some things still might fail.
Turing.jl is a Julia library for (universal) probabilistic programming. Current features include:
- Universal probabilistic programming with an intuitive modelling interface
- Hamiltonian Monte Carlo (HMC) sampling for differentiable posterior distributions
- Particle MCMC sampling for complex posterior distributions involving discrete variables and stochastic control flows
- Gibbs sampling that combines particle MCMC, HMC and many other MCMC algorithms
To use Turing, you need to first install Julia. You will need to Julia 1.0 or greater, which you can get from the official Julia website. Once you have installing Julia, you need to add Turing to your Julia environment. Turing is an officially registered Julia package, so the following will install a stable version of Turing while inside Julia's package manager (press ]
from the REPL):
add Turing
If you want to use the latest version of Turing with some experimental features, you can try the following instead:
add Turing#master
test Turing
Here's a simple example showing the package in action:
using Turing
using Plots
# Define a simple Normal model with unknown mean and variance.
@model gdemo(x, y) = begin
s ~ InverseGamma(2,3)
m ~ Normal(0,sqrt(s))
x ~ Normal(m, sqrt(s))
y ~ Normal(m, sqrt(s))
return s, m
end
# Run sampler, collect results
c1 = sample(gdemo(1.5, 2), SMC(1000))
c2 = sample(gdemo(1.5, 2), PG(10,1000))
c3 = sample(gdemo(1.5, 2), HMC(1000, 0.1, 5))
c4 = sample(gdemo(1.5, 2), Gibbs(1000, PG(10, 2, :m), HMC(2, 0.1, 5, :s)))
c5 = sample(gdemo(1.5, 2), HMCDA(1000, 0.15, 0.65))
c6 = sample(gdemo(1.5, 2), NUTS(1000, 0.65))
# Summarise results (currently requires the master branch from MCMCChain)
describe(c3)
# Plot and save results
p = plot(c3)
savefig("gdemo-plot.png")
Turing was originally created and is now managed by Hong Ge. Current and past Turing team members include Hong Ge, Adam Scibior, Matej Balog, Zoubin Ghahramani, Kai Xu, Emma Smith, Emile Mathieu, Martin Trapp. You can see the full list of on Github: https://github.com/TuringLang/Turing.jl/graphs/contributors.
Turing is an open source project so if you feel you have some relevant skills and are interested in contributing then please do get in touch. See the Contribute wiki page for details on the process. You can contribute by opening issues on Github or implementing things yourself and making a pull request. We would also appreciate example models written using Turing.
If you use Turing for your own research, please consider citing the following publication: Hong Ge, Kai Xu, and Zoubin Ghahramani: Turing: Composable inference for probabilistic programming. AISTATS 2018 pdf bibtex