You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some text about how easy it is to [get going](https://turinglang.org/docs/tutorials/00-introduction/).
38
+
The [modelling syntax of Turing.jl](https://turinglang.org/docs/core-functionality) closely resembles the mathematical specification of a probabilistic model.
39
+
For example, the following model describes a coin flip experiment with `N` flips, where `p` is the probability of heads.
40
+
41
+
```math
42
+
\begin{align*}
43
+
p &\sim \text{Beta}(1, 1) \\
44
+
y_i &\sim \text{Bernoulli}(p) \quad \text{for } i = 1, \ldots, N
45
+
```
39
46
40
47
:::
41
48
42
49
::: {.example-code style="overflow-x: scroll;"}
43
50
```{.julia .code-overflow-scroll}
51
+
# Define the model
44
52
@model function coinflip(; N::Int)
45
-
# Prior belief about the probability of heads
46
53
p ~ Beta(1, 1)
47
-
48
-
# Heads or tails of a coin are drawn from `N`
49
-
# Bernoulli distributions with success rate `p`
50
54
y ~ filldist(Bernoulli(p), N)
55
+
end
51
56
52
-
end;
57
+
# Condition on data
58
+
data = [0, 1, 1, 0, 1]
59
+
model = coinflip(; N = length(data)) | (; y = data)
53
60
```
54
61
:::
55
62
@@ -59,22 +66,90 @@ end;
59
66
60
67
::: {.example-text style="padding:0.5rem;"}
61
68
62
-
<divclass="fs-4 fw-bold pb-1">Goodbye, World in Turing</div>
A number of MCMC sampling algorithms are available in Turing.jl, including (but not limited to) HMC, NUTS, Metropolis–Hastings, particle samplers, and Gibbs.
63
99
64
-
Some text about how easy it is to interface with external packages like AbstractGPs. Learn more about modelling [Gaussian Processes](https://turinglang.org/docs/tutorials/15-gaussian-processes/)with Turing.jl.
100
+
Turing.jl also supports ['external samplers'](https://turinglang.org/docs/usage/external-samplers/)which conform to the AbstractMCMC.jl interface, meaning that users can implement their own algorithms.
<divclass="fs-4 fw-bold pb-1">Composability with Julia</div>
122
+
123
+
As Turing.jl models are simply Julia functions under the hood, they can contain arbitrary Julia code.
124
+
125
+
For example, [differential equations](https://turinglang.org/docs/tutorials/bayesian-differential-equations/) can be added to a model using `DifferentialEquations.jl`, which is a completely independent package.
126
+
127
+
:::
128
+
129
+
::: {.example-code style="overflow-x: scroll;"}
130
+
```{.julia .code-overflow-scroll}
131
+
using DifferentialEquations
132
+
133
+
# Define the system of equations
134
+
function lotka_volterra(du, u, params, t)
135
+
α, β, δ, γ = params
136
+
x, y = u
137
+
du[1] = (α * x) - (β * x * y)
138
+
du[2] = (δ * x * y) - (γ * y)
139
+
end
140
+
prob = ODEProblem(lotka_volterra, ...)
141
+
142
+
# Use it in a model
143
+
@model function fit_lotka_volterra()
144
+
# Priors
145
+
α ~ Normal(0, 1)
146
+
# ...
147
+
148
+
# Solve the ODE
149
+
predictions = solve(prob, Tsit5(); p=p)
150
+
151
+
# Likelihood
152
+
data ~ Poisson.(predictions, ...)
78
153
end
79
154
```
80
155
:::
@@ -179,4 +254,4 @@ Placeholder text introducing the Bayesian Workflow diagram from the ACM special
0 commit comments