Comments (11)
https://github.com/DominiqueMakowski/CognitiveModels/blob/main/content/media/animations_rt.jl#L351
from sequentialsamplingmodels.jl.
Unfortunately, that approach doesn't generalize well for SSMs with more than 1 accumulators.
There are some alternatives that I considered, but their design tradeoffs do not result in a clear net gain. For example, simulate
could return a matrix with time in the first column and samples from the other accumulators in the other columns. With this approach, its not possible to use plot(simulate(model))
because the matrix needs to be sliced. I could stack the matrices following map
, but the simulation id would be lost. A similar alternative would be to add a simulation id and throw it into a dataframe, but that still doesn't integrate well with Plots or StatsPlots because it requires explicitly calling column names in the plotting function. Although not perfect, the current set up is simple and integrates well with Plots. If I want to plot multiple traces of the RDM and color code the accumulators, I can run this:
p = plot(); foreach(_ -> plot!(p, simulate(RDM()), color = [:red :black], leg = false), 1:4); p
No need to worry about padding with Missing
.
The integration with Makie is poor, but as far as I can tell, the alternatives do not integrate any better. Here, you have to iterate over each accumulator (as far as I can tell):
using Makie
fig = Figure()
ax = Axis(fig[1, 1], yautolimitmargin = (0.2, 0.2))
times, evidence = simulate(RDM())
map(e -> lines!(ax, times, e), eachcol(evidence))
If you wrap that in a function, it is possible to iterate over multiple traces without need for padding.
from sequentialsamplingmodels.jl.
I don't know if you need to use a DataFrame for the purposes of plotting, but I think simulate
is the method you are looking for.
using DataFrames
using SequentialSamplingModels
model = RDM()
_,trace = simulate(model)
df = DataFrame(trace, :auto)
from sequentialsamplingmodels.jl.
In terms of plotting, you can do the following:
using Plots
using SequentialSamplingModels
model = RDM()
times,trace = simulate(model)
plot(times, trace)
If you want to plot the accumulation process incrementally, you can do something like this:
using GLMakie
using SequentialSamplingModels
model = RDM()
times, evidence = simulate(model)
idx = Observable(1)
ys_1 = @lift(evidence[$idx,1])
ys_2 = @lift(evidence[$idx,2])
fig = lines(times, ys_1, color = :blue, linewidth = 4,
axis = (title = @lift("t = $(round(times[$idx], digits = 1))"),))
lines!(times, ys_2, color = :red, linewidth = 4)
indices = 1:length(times)
record(fig, "time_animation.mp4", indices;
framerate = length(times)) do i
println("i $i")
idx[] = i
end
update
This code is closer, but it throws a type error. I'm not familiar with Makie, so its not immediately clear how to fix the problem. Another improvement would be to generate the lines programatically based on the number of columns in evidence
.
from sequentialsamplingmodels.jl.
I managed to animate the way I wanted :) Thanks a lot!
See here the result
from sequentialsamplingmodels.jl.
No problem. If the animation code was written in Julia, do you mind sharing it?
from sequentialsamplingmodels.jl.
Thanks. Do you know how to generalize to the case with an arbitrary number of options? That was one of the problems I had above.
from sequentialsamplingmodels.jl.
Maybe I need to make a vector of points similar to points = [(i, j) for (i, j) in zip(x, trace)]
in your code, but adapt it for multiple accumulators rather than simulations
from sequentialsamplingmodels.jl.
Thanks. Do you know how to generalize to the case with an arbitrary number of options?
Not at the moment, I spent my day on it fighting Makie and my brain is fried 😅
The trick bit was to figure out when to use @lift()
and Observable()
from sequentialsamplingmodels.jl.
fighting Makie and my brain is fried
Haha. I feel the same.
from sequentialsamplingmodels.jl.
Perhaps I would consider adding an arguments like n_traces=1
in the simulate()
methods that would return a matrix of n traces, of the length of the longest and potentially filled with missing.
from sequentialsamplingmodels.jl.
Related Issues (20)
- Testing ext across different machines HOT 1
- predict() broken? HOT 6
- LBA docs minor HOT 2
- Update version HOT 19
- Issue with pdf for WaldMixture HOT 5
- Increment Version HOT 23
- Simulating trial-level and hierarchical data HOT 10
- LNR model makes off-scale predictions for 1-choice data? HOT 7
- Minor docs: LBA args HOT 1
- Parametrizing RDM: "ERROR: DomainError with ..." log error HOT 4
- Standardize positional arguments for constructors.
- Wald model: domain error (InverseGaussian: the condition μ > zero(μ) is not satisfied) HOT 7
- fit() method: is it possible? HOT 7
- Adding Shifted Lognormal HOT 19
- ExGaussian: lower limit of Tau is ~.005? HOT 4
- Increment Version HOT 3
- Minor docs HOT 5
- Unified Wald constructor HOT 11
- DDM: z or beta? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sequentialsamplingmodels.jl.