From bcb8c9af49199bf80adab21f41b42fb7eb0a94c7 Mon Sep 17 00:00:00 2001 From: itsdfish Date: Sat, 30 Sep 2023 14:57:59 -0400 Subject: [PATCH] update type system --- Project.toml | 2 +- docs/src/bayes_factor.md | 9 +++++++-- src/SequentialSamplingModels.jl | 1 + src/type_system.jl | 6 +++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index f57b59f2..dd0191ba 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SequentialSamplingModels" uuid = "0e71a2a6-2b30-4447-8742-d083a85e82d1" authors = ["itsdfish"] -version = "0.7.1" +version = "0.7.2" [deps] Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" diff --git a/docs/src/bayes_factor.md b/docs/src/bayes_factor.md index 42d1e102..af016988 100644 --- a/docs/src/bayes_factor.md +++ b/docs/src/bayes_factor.md @@ -8,8 +8,13 @@ In this tutorial, we will use the Bayes factor to compare the evidence for one m In the tutorial below, we will compare two models which differ only in terms of assumptions about drift rate variability: the LBA and the RDM. The LBA assumes that the drift rate varies across trials and is otherwise deterministic, whereas the RDM assumes the drift rate varies within a trial as Gaussian noise, but not across trials. The difference between the models can be visualized with SSMPlots.jl: ### RDM +```@setup bayes_factor +using Random +using SequentialSamplingModels +using SSMPlots +``` -```julia +```@example bayes_factor using SequentialSamplingModels using SSMPlots using Random @@ -20,7 +25,7 @@ density_kwargs=(;t_range=range(.20, 1.0, length=100),) plot_model(dist; n_sim=1, density_kwargs, xlims=(0,1.0)) ``` ### LBA -```julia +```@example bayes_factor using SequentialSamplingModels using SSMPlots using Random diff --git a/src/SequentialSamplingModels.jl b/src/SequentialSamplingModels.jl index 29defd58..967ee941 100644 --- a/src/SequentialSamplingModels.jl +++ b/src/SequentialSamplingModels.jl @@ -31,6 +31,7 @@ module SequentialSamplingModels import StatsAPI: params export AbstractaDDM + export AbstractCDDM export AbstractLBA export AbstractLCA export AbstractLNR diff --git a/src/type_system.jl b/src/type_system.jl index 2bf94fd2..f95f327d 100644 --- a/src/type_system.jl +++ b/src/type_system.jl @@ -83,6 +83,7 @@ struct Approximate <: PDFType end get_pdf_type(d::SSM1D) = Exact get_pdf_type(d::SSM2D) = Exact +get_pdf_type(d::ContinuousMultivariateSSM) = Exact minimum(d::SSM1D) = 0.0 maximum(d::SSM1D) = Inf @@ -94,6 +95,7 @@ insupport(d::SSM2D, data) = data.rt ≥ minimum(d) && data.rt ≤ maximum(d) Base.broadcastable(x::SSM1D) = Ref(x) Base.broadcastable(x::SSM2D) = Ref(x) +Base.broadcastable(x::ContinuousMultivariateSSM) = Ref(x) vectorize(d::SSM2D, r::NamedTuple) = [r...] reconstruct(d::SSM2D, v::NamedTuple) = deepcopy(v) @@ -185,4 +187,6 @@ Returns 1 for the number of choice options - `d::SSM1D`: a sub-type of `SSM1D` """ -n_options(d::SSM1D) = 1 \ No newline at end of file +n_options(d::SSM1D) = 1 + +n_options(d::ContinuousMultivariateSSM) = length(d.ν) \ No newline at end of file