Skip to content

Commit 9a80bb4

Browse files
committed
update simulate for lba, lnr, update doc strings
1 parent 1881223 commit 9a80bb4

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
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.11.13"
4+
version = "0.12.0"
55

66
[deps]
77
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"

src/LBA.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,17 @@ represent samples of evidence per time step and columns represent different accu
229229
230230
# Keywords
231231
232-
- `n_steps=100`: number of time steps at which evidence is recorded
232+
- `Δt = 0.001`: the time step
233233
"""
234-
function simulate(rng::AbstractRNG, model::AbstractLBA; Δt = 0.01, _...)
235-
(; τ, A, k, ν, σ) = model
234+
function simulate(rng::AbstractRNG, model::AbstractLBA; Δt = 0.001, _...)
235+
(; A, k, ν, σ) = model
236236
b = A + k
237237
n = length(ν)
238238
νs = sample_drift_rates(rng, ν, σ)
239-
a = rand(rng,Uniform(0, A), n)
239+
a = rand(rng, Uniform(0, A), n)
240240
dt = @. (b - a) / νs
241-
choice, t = select_winner(dt)
242-
evidence = collect.(range.(a, a + νs * t, step = Δt))
243-
time_steps = range(0, t, length=length(evidence[1]))
241+
_, t = select_winner(dt)
242+
time_steps = range(0, t, step = Δt) # Define time steps first with Δt
243+
evidence = collect.(range.(a, a + νs * t, length = length(time_steps))) # Match evidence to time steps
244244
return time_steps, hcat(evidence...)
245245
end

src/LNR.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,15 @@ represent samples of evidence per time step and columns represent different accu
122122
123123
# Keywords
124124
125-
- `n_steps=100`: number of time steps at which evidence is recorded
125+
- `Δt = 0.001`: the time step
126126
"""
127-
function simulate(rng::AbstractRNG, model::AbstractLNR; n_steps = 100, _...)
128-
(; τ, ν, σ) = model
129-
n = length(ν)
127+
function simulate(rng::AbstractRNG, model::AbstractLNR; Δt = 0.001, _...)
128+
(; ν, σ) = model
130129
νs = @. rand(rng, Normal(ν, σ))
131130
βs = @. exp(νs)
132131
_, choice = findmax(βs)
133132
t = 1 / βs[choice]
134-
evidence = collect.(range.(0, βs * t, length = 100))
135-
time_steps = range(0, t, length = n_steps)
133+
time_steps = range(0, t, step = Δt)
134+
evidence = collect.(range.(0, βs * t, length = length(time_steps)))
136135
return time_steps, hcat(evidence...)
137136
end

test/lba_tests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
α = A + k
103103
dist = LBA(; A, k, ν = [2, 1])
104104

105-
time_steps, evidence = simulate(dist; n_steps = 100)
105+
time_steps, evidence = simulate(dist; Δt = 0.001)
106106

107107
@test time_steps[1] 0
108108
@test length(time_steps) == size(evidence, 1)

0 commit comments

Comments
 (0)