Skip to content

Feat/ssm ext#51

Open
rsenne wants to merge 5 commits into
mainfrom
feat/SSMExt
Open

Feat/ssm ext#51
rsenne wants to merge 5 commits into
mainfrom
feat/SSMExt

Conversation

@rsenne

@rsenne rsenne commented Jul 12, 2026

Copy link
Copy Markdown
Owner
  • Adds EmissionModelsSequentialSamplingModelsExt
  • Adds StimulusCodedDDM" and CoherenceDDM`
  • Adds ACDC drivers for robust model selection
  • Also fixes a bug where no ControlledEmissionHMM worked with ACDC

Resolves #34

rsenne added 3 commits July 12, 2026 14:49
Three tutorials in examples/ (basics, GLM emissions, ACDC model
selection) in the style of HiddenMarkovModels.jl: Literate.jl scripts
whose @test lines are hidden from the rendered docs with #src but run
as part of the package test suite. docs/make.jl converts them into a
Tutorials section, and test/runtests.jl includes each example as a
testset.
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.67550% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.36%. Comparing base (8634168) to head (e852886).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
ext/EmissionModelsSequentialSamplingModelsExt.jl 94.44% 1 Missing ⚠️
src/ssm/ddm.jl 99.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
+ Coverage   99.12%   99.36%   +0.23%     
==========================================
  Files           7        9       +2     
  Lines        1257     1408     +151     
==========================================
+ Hits         1246     1399     +153     
+ Misses         11        9       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1)

Time benchmarks
main e852886... main / e852886...
fit!/BernoulliGLM 0.186 ± 0.002 ms 0.187 ± 0.0023 ms 0.998 ± 0.016
fit!/GaussianGLM 11.4 ± 0.05 μs 11.4 ± 0.06 μs 1 ± 0.0068
fit!/MultivariateT 2.34 ± 0.013 ms 2.37 ± 0.013 ms 0.988 ± 0.0078
fit!/MultivariateTDiag 0.48 ± 0.0091 ms 0.479 ± 0.0086 ms 1 ± 0.026
fit!/MvBernoulliGLM 0.366 ± 0.0092 ms 0.367 ± 0.0092 ms 0.998 ± 0.035
fit!/MvGaussianGLM 21.3 ± 0.27 μs 21.2 ± 0.24 μs 1 ± 0.017
fit!/MvPoissonGLM 0.24 ± 0.008 ms 0.241 ± 0.0078 ms 0.997 ± 0.046
fit!/PoissonGLM 0.183 ± 0.0033 ms 0.183 ± 0.0033 ms 0.998 ± 0.025
fit!/PoissonZeroInflated 8.19 ± 0.04 μs 8.19 ± 0.05 μs 1 ± 0.0078
logdensityof/BernoulliGLM 11.6 ± 0.011 μs 11.6 ± 0.029 μs 0.995 ± 0.0027
logdensityof/GaussianGLM 6.26 ± 0.02 μs 6.24 ± 0.02 μs 1 ± 0.0045
logdensityof/MultivariateT 0.0685 ± 0.00061 ms 0.0684 ± 0.00067 ms 1 ± 0.013
logdensityof/MultivariateTDiag 25.8 ± 0.11 μs 26.1 ± 0.07 μs 0.991 ± 0.005
logdensityof/MvBernoulliGLM 23.2 ± 0.03 μs 23.2 ± 0.02 μs 1 ± 0.0016
logdensityof/MvGaussianGLM 0.0439 ± 0.0012 ms 0.0433 ± 0.00074 ms 1.02 ± 0.032
logdensityof/MvPoissonGLM 19.7 ± 0.04 μs 20.1 ± 0.041 μs 0.983 ± 0.0028
logdensityof/PoissonGLM 11.1 ± 0.02 μs 11.1 ± 0.029 μs 1.01 ± 0.0032
logdensityof/PoissonZeroInflated 17.8 ± 0.021 μs 17.7 ± 0.031 μs 1 ± 0.0021
rand!/MultivariateT 0.16 ± 0.011 μs 0.151 ± 0.011 μs 1.06 ± 0.11
rand!/MultivariateTDiag 0.1 ± 0 μs 0.1 ± 0 μs 1 ± 0
rand!/MvBernoulliGLM 0.08 ± 0 μs 0.08 ± 0.001 μs 1 ± 0.013
rand!/MvGaussianGLM 0.12 ± 0.001 μs 0.12 ± 0.01 μs 1 ± 0.084
rand!/MvPoissonGLM 0.131 ± 0.02 μs 0.131 ± 0.02 μs 1 ± 0.22
rand/BernoulliGLM 0.06 ± 0.001 μs 0.06 ± 0.01 μs 1 ± 0.17
rand/GaussianGLM 0.04 ± 0 μs 0.04 ± 0 μs 1 ± 0
rand/PoissonGLM 0.06 ± 0.011 μs 0.06 ± 0.011 μs 1 ± 0.26
rand/PoissonZeroInflated 0.06 ± 0.011 μs 0.06 ± 0.02 μs 1 ± 0.38
time_to_load 0.952 ± 0.0072 s 0.988 ± 0.003 s 0.963 ± 0.0079
Memory benchmarks
main e852886... main / e852886...
fit!/BernoulliGLM 0.139 k allocs: 6.02 kB 0.139 k allocs: 6.02 kB 1
fit!/GaussianGLM 4 allocs: 0.188 kB 4 allocs: 0.188 kB 1
fit!/MultivariateT 0.099 k allocs: 9.13 kB 0.099 k allocs: 9.13 kB 1
fit!/MultivariateTDiag 11 allocs: 4.32 kB 11 allocs: 4.32 kB 1
fit!/MvBernoulliGLM 0.28 k allocs: 12.2 kB 0.28 k allocs: 12.2 kB 1
fit!/MvGaussianGLM 10 allocs: 0.516 kB 10 allocs: 0.516 kB 1
fit!/MvPoissonGLM 0.28 k allocs: 12.2 kB 0.28 k allocs: 12.2 kB 1
fit!/PoissonGLM 0.183 k allocs: 7.78 kB 0.183 k allocs: 7.78 kB 1
fit!/PoissonZeroInflated 0 allocs: 0 B 0 allocs: 0 B
logdensityof/BernoulliGLM 0 allocs: 0 B 0 allocs: 0 B
logdensityof/GaussianGLM 0 allocs: 0 B 0 allocs: 0 B
logdensityof/MultivariateT 1 k allocs: 0.0381 MB 1 k allocs: 0.0381 MB 1
logdensityof/MultivariateTDiag 0 allocs: 0 B 0 allocs: 0 B
logdensityof/MvBernoulliGLM 0 allocs: 0 B 0 allocs: 0 B
logdensityof/MvGaussianGLM 1 k allocs: 0.0381 MB 1 k allocs: 0.0381 MB 1
logdensityof/MvPoissonGLM 0 allocs: 0 B 0 allocs: 0 B
logdensityof/PoissonGLM 0 allocs: 0 B 0 allocs: 0 B
logdensityof/PoissonZeroInflated 0 allocs: 0 B 0 allocs: 0 B
rand!/MultivariateT 0 allocs: 0 B 0 allocs: 0 B
rand!/MultivariateTDiag 0 allocs: 0 B 0 allocs: 0 B
rand!/MvBernoulliGLM 0 allocs: 0 B 0 allocs: 0 B
rand!/MvGaussianGLM 0 allocs: 0 B 0 allocs: 0 B
rand!/MvPoissonGLM 0 allocs: 0 B 0 allocs: 0 B
rand/BernoulliGLM 0 allocs: 0 B 0 allocs: 0 B
rand/GaussianGLM 0 allocs: 0 B 0 allocs: 0 B
rand/PoissonGLM 0 allocs: 0 B 0 allocs: 0 B
rand/PoissonZeroInflated 0 allocs: 0 B 0 allocs: 0 B
time_to_load 0.149 k allocs: 11.1 kB 0.149 k allocs: 11.1 kB 1

@rsenne

rsenne commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

cc @itsdfish @kiante-fernandez can one / both of y'all review this? I guess one question is if any of the code related to the Signed / Coherence DDM should live upstream. Happy to move things around. As we discussed one of these could also just live as an example in a Literate tutorial as well

@itsdfish

Copy link
Copy Markdown

cc @itsdfish @kiante-fernandez can one / both of y'all review this? I guess one question is if any of the code related to the Signed / Coherence DDM should live upstream. Happy to move things around. As we discussed one of these could also just live as an example in a Literate tutorial as well

@rsenne, I will look over your code and and markdown over the next couple days and try to provide some high level feedback. I'm still having issues with typing. So I can't get into the code in a lot of depth and interact with it. But I look forward to learning about your model and how it hooks into SSM.jl.

@rsenne

rsenne commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

No worries, thanks for all the help, even with a hand injury :) happy to answer any questions / if anything looks funky let me know

Comment thread examples/acdc.jl

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this perform if the number of states are correct but the mission distributions are misspecified?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question. I’m not the original author of this method, but let me tag @nguyenston, who adapted it for use with HMMs.

My understanding is that ACDC is designed with the expectation that some degree of model misspecification will almost always be present. Rather than assuming the fitted model is exactly correct, it aims to select $K$ by minimizing the relevant discrepancy.

It may be helpful to distinguish between two levels of misspecification. In a common case, the observation model may capture the broad structure of the data but miss some distributional details. For example, the data may be approximately Gaussian overall, while one or more latent-state distributions are closer to gamma distributions and exhibit right skew. In settings like this, ACDC can help reduce the tendency of mixture models and HMMs to compensate for the misspecified emission distribution by introducing extra components or states. In other words, it may help prevent over-segmentation caused by using multiple Gaussian components to approximate a single non-Gaussian distribution.

The situation is different when there is a substantial mismatch between the assumed observation model and the true data-generating process. In that case, ACDC may still identify the value of K that minimizes discrepancy within the specified model class, but it cannot correct the model class itself. The selected number of components or states could therefore remain difficult to interpret, since additional states may be used to absorb systematic features that the observation model cannot represent.

@rsenne rsenne marked this pull request as ready for review July 14, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add SequentialSamplingModels extension

2 participants