Skip to content

Commit 1b8b0e7

Browse files
committed
expand compat for Turing, increment version
1 parent 37e5a93 commit 1b8b0e7

File tree

4 files changed

+49
-7
lines changed

4 files changed

+49
-7
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SequentialSamplingModels"
22
uuid = "0e71a2a6-2b30-4447-8742-d083a85e82d1"
33
authors = ["itsdfish"]
4-
version = "0.12.3"
4+
version = "0.12.4c"
55

66
[deps]
77
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
@@ -44,7 +44,7 @@ SpecialFunctions = "1,2"
4444
Statistics = "1"
4545
StatsAPI = "1.0.0"
4646
StatsBase = "0.33.0,0.34.0"
47-
Turing = "0.29.0,0.30.0,0.31.0,0.32,0.33,0.34.0,0.35.0,0.36.0,0.37,0.38.0"
47+
Turing = "0.35.0,0.36.0,0.37,0.38.0,0.39.0"
4848
julia = "1"
4949

5050
[extras]

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ Plots = "1.0.0"
2828
StatsBase = "0.33.0,0.34.0"
2929
StatsModels = "0.7.0"
3030
StatsPlots = "0.15.0"
31-
Turing = "0.33.0,0.34,0.35.0,0.36.0, 0.37.0"
31+
Turing = "0.33.0,0.34,0.35.0,0.36.0, 0.37.0, 0.38.0, 0.39.0"

docs/src/predictive_distributions.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,52 @@
22

33
This tutorial explains the steps required for constructing and plotting prior and posterior predictive distributions of a sequential sampling models (SSMs). The primary function we will be using is `predict_distribution`, which allows you to generate prior or posterior predictive distributions from a given model.
44

5+
## Full Code
6+
7+
You can reveal copy-and-pastable version of the full code by clicking the ▶ below.
8+
9+
```@raw html
10+
<details>
11+
<summary><b>Show Full Code</b></summary>
12+
```
13+
```julia
14+
using Distributions
15+
using Plots
16+
using Random
17+
using SequentialSamplingModels
18+
using Turing
19+
Random.seed!(1124)
20+
21+
n_samples = 50
22+
rts = rand(Wald=1.5, α=.8, τ=.3), n_samples)
23+
24+
@model function wald_model(rts)
25+
ν ~ truncated(Normal(1.5, 1), 0, Inf)
26+
α ~ truncated(Normal(.8, 1), 0, Inf)
27+
τ = 0.3
28+
rts ~ Wald(ν, α, τ)
29+
return (;ν, α, τ)
30+
end
31+
32+
model = wald_model(rts)
33+
34+
prior_chain = sample(model, Prior(), 1000)
35+
36+
pred_model = predict_distribution(Wald; model, func=mean, n_samples)
37+
prior_preds = generated_quantities(pred_model, prior_chain)
38+
39+
post_chain = sample(model, NUTS(1000, .85), 1000)
40+
post_preds = generated_quantities(pred_model, post_chain)
41+
42+
histogram(prior_preds[:], xlims=(0,4), xlabel="Mean RT", ylabel="Density", norm=true,
43+
color=:grey, label="prior", grid=false)
44+
histogram!(post_preds[:], alpha=.7, color=:darkred, norm=true, label="posterior", grid=false)
45+
vline!([mean(rts)], linestyle=:dash, color=:black, linewidth=2, label="data")
46+
```
47+
```@raw html
48+
</details>
49+
```
50+
551
# Example
652
The first step is to load the required packages and set the seed for the random number generator.
753

ext/TuringExt.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module TuringExt
22

3-
import DynamicPPL: reconstruct
4-
import DynamicPPL: vectorize
53
import DynamicPPL: tovec
64
using SequentialSamplingModels
75
import SequentialSamplingModels: predict_distribution
@@ -31,8 +29,6 @@ Generates a predictive distribution for a statistic defined by `func`.
3129
return func(sim_data, args...; kwargs...)
3230
end
3331

34-
vectorize(d::SSM2D, r::NamedTuple) = [r...]
35-
reconstruct(d::SSM2D, v::NamedTuple) = deepcopy(v)
3632
tovec(x::@NamedTuple{choice::C, rt::R}) where {C <: Integer, R <: AbstractFloat} =
3733
[x.choice, x.rt]
3834
end

0 commit comments

Comments
 (0)