Skip to content

Commit

Permalink
Merge pull request #25 from DominiqueMakowski/master
Browse files Browse the repository at this point in the history
Add brief example on main doc page to give a "feel" of the package
  • Loading branch information
itsdfish committed Jun 20, 2023
2 parents e012bd3 + 18c230d commit 668a68b
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# SequentialSamplingModels.jl

Documentation is under construction.
**Documentation is under construction.**

This package is a collection of sequential sampling models and is based on the Distributions.jl API.
Sequential sampling models, also known as an evidence accumulation models, are a broad class of dynamic models of human decision making in which evidence for each option accumulates until the evidence for one option reaches a decision threshold. Models within this class make different assumptions about the nature of the evidence accumulation process. See the references below for a broad overview of sequential sampling models. An example of the evidence accumulation process is illustrated below for the leaking competing accumulator.
This package is a collection of sequential sampling models in Julia and is based on the Distributions.jl API.
Sequential sampling models, also known as an evidence accumulation models, are a broad class of dynamic models of human decision making in which evidence for each option accumulates until the evidence for one option reaches a decision threshold. Models within this class make different assumptions about the nature of the evidence accumulation process. See the references below for a broad overview of sequential sampling models. An example of the evidence accumulation process is illustrated below for the leaking competing accumulator.

```@setup accumulation
using Plots
Expand All @@ -14,7 +14,7 @@ using SequentialSamplingModels: increment!
Random.seed!(8437)
function sim(model)
n = length(model.ν)
x = fill(0.0, n)
μΔ = fill(0.0, n)
Expand All @@ -26,21 +26,21 @@ function sim(model)
t += Δt
increment!(model, x, μΔ, ϵ)
push!(evidence, copy(x))
end
end
return t,evidence
end
parms = (α = 1.5,
parms = (α = 1.5,
β=0.20,
λ=0.10,
ν=[2.5,2.0],
Δt=.001,
τ=.30,
λ=0.10,
ν=[2.5,2.0],
Δt=.001,
τ=.30,
σ=1.0)
model = LCA(; parms...)
t,evidence = sim(model)
n_steps = length(evidence)
time_steps = range(0, t, length=n_steps)
lca_plot = plot(time_steps, hcat(evidence...)', xlabel="Time (seconds)", ylabel="Evidence",
lca_plot = plot(time_steps, hcat(evidence...)', xlabel="Time (seconds)", ylabel="Evidence",
label=["option1" "option2"], ylims=(0, 2.0), grid=false, linewidth = 2,
color =[RGB(148/255, 90/255, 147/255) RGB(90/255, 112/255, 148/255)])
hline!(lca_plot, [model.α], color=:black, linestyle=:dash, label="threshold", linewidth = 2)
Expand All @@ -50,7 +50,7 @@ savefig("lca_plot.png")
![](lca_plot.png)
# Installation

You can install a stable version of SequentialSamplingModels by running the following in the Julia REPL:
You can install a stable version of *SequentialSamplingModels* by running the following in the Julia REPL:

```julia
] add SequentialSamplingModels
Expand All @@ -62,6 +62,26 @@ The package can then be loaded with:
using SequentialSamplingModels
```

# Quick Example

The package implements sequential sampling models as distributions, that we can use you estimate the likelihood, or generate data from. In the example below, we instantiate a Linear Ballistic Accumulator (LBA) model, and generate data from it.

```julia
using StatsPlots

# Create LBA distribution with known parameters
dist = LBA(; ν=[0, 0.5], A=0.2, k=0.8, τ=0.3)
# Sample 1000 random data points from this distribution
choice, rt = rand(dist, 1000)

# Plot the RT distribution for each choice
histogram(layout=(2, 1), xlabel="Reaction Time", ylabel="Density", xlims = (0,5))
histogram!(rt[choice.==1], subplot=1, color=:green)
histogram!(rt[choice.==2], subplot=2, color=:red)
```

*SequentialSamplingModels* provides such unified interface to a variety of models.

# References
Evans, N. J. & Wagenmakers, E.-J. Evidence accumulation models: Current limitations and future directions. Quantitative Methods for Psychololgy 16, 73–90 (2020).

Expand Down

0 comments on commit 668a68b

Please sign in to comment.