Repository navigation
Conversation
Brings the somata port (originally committed on `main`) over to `dev` and adapts it to the changes dev has accumulated since the branches diverged. Carried over unchanged: - `src/somata/` — oscillator, AR(p), composite state models, dOsc search, residual diagnostics - `src/numerics/block_diagonal.jl`, the `IGPrior`/`VMPrior` scalar priors - `benchmark/somata/`, `test/Somata/`, `docs/examples/Somata.jl` Adapted to dev: - `src/stats/kalman.jl` was deleted on dev (depasquale-lab#152); its somata-side edits were pure signature widening, so they drop out with the file. - `AbstractLinearGaussianStateModel` widening re-applied to dev's rewritten `fit_LDS.jl` / `fit_PLDS.jl` / `workspaces.jl` / `sufficient_statistics.jl`. The four overridable M-step hooks stay narrowed to `GaussianStateModel` so they remain the *unconstrained* implementations. - New `_x0_prior` accessor for dev's `x0_prior` field (depasquale-lab#156): `OscillatorStateModel` does not override `update_initial_state_mean!`, so the generic update runs for it and must not assume the field exists. - `_state_logprior` absorbs dev's inline state-prior blocks in both `elbo!`s and gains dev's `x0_prior` term. - `_extract_state_params` widened to the abstract supertype. - `init_yy` is a raw `Ref{Matrix}` on dev rather than a PDMat, so the two somata `_update_P0_block!` kernels read it without `.mat`. - `sparse_hessian` / `steady_state_tol` re-plumbed through dev's `SmoothWorkspace`, plus the pool-size cap on `_fit_tridiag!`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- `_td_init_const_blocks!` / `estep!` take a `Data` object on dev, so the three `test/Somata` sufficient-statistic helpers build one instead of passing `(tsteps, y, ux, uy)` positionally. - `fit!` input kwargs are `ux` / `uy` on dev, not `latent_inputs` / `obs_inputs`; `lds.state_input_dim` is `lds.ux_dim`. - `_slds_prior_logdensity` read `state_model.Q_prior` and friends directly, which throws a `FieldError` for structured regimes. Routed through the `_q_prior` / `_p0_prior` / `_x0_prior` / `_ab_prior` accessors. - Widened `loglikelihood` / `_filter_cov_pass` / `_filter_ll_trial` (dev's Kalman marginal-likelihood path, which names its state parameter `SM` and so was missed by the first widening pass). - Retargeted the workspace prior-accessor regression test at `elbo`, since the `KalmanWorkspace` it asserted against was retired on dev; extended the accessor test to cover `_x0_prior`. - JuliaFormatter pass (the longer abstract type name rewraps several `where` clauses). Full suite: 2711 pass. The one remaining error is Aqua's "Persistent tasks" check failing to locate `ChangesOfVariables`, which reproduces identically on stock dev and is unrelated to this work. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Docs (`julia --project=docs docs/make.jl` now exits 0, doctests included): - The `@docs` signatures in `api.md` / `LinearDynamicalSystems.md` still named `GaussianStateModel`, so seven widened methods no longer matched any listed signature and tripped Documenter's `missing_docs` check. - Four `@ref`s to the structured models sat in *parent*-module docstrings (`lds/types.jl`, `stats/priors.jl`), where the unqualified name does not resolve — the types register as `Somata.X`. Qualified them, matching the existing usage in `numerics/block_tridiagonal.jl`. Benchmark rerun on this branch against somata 0.5.6 (30 configurations, 25 EM iterations, median of 3 repeats): - median speedup 8.4x -> 9.0x; every configuration within 0.89-1.23x of its previous value, so no regression beyond run-to-run noise. - the parity metrics match the pre-port run to ~1e-7 relative, i.e. the port is numerically unchanged; the documented somata-vs-Julia gaps (the O(1/T) boundary convention and the AR `q_floor`) are unaffected. - the in-process fairness audit reproduces: median 1.074 (was 1.073), range 1.052-1.102 (was 1.053-1.102). Results tables in both READMEs updated. `benchmark/somata/results/` is gitignored, so the regenerated CSVs and figures stay local. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`dosc` takes `fs` as a keyword, not positionally, so the README snippet threw a MethodError as written. Pre-existing (the signature changed in cbbfaaf without the README following), not introduced by the port. Every numerical claim in that section reproduces exactly on this branch: `ncomps` = 3, selected frequencies [2.09, 9.99, 22.15] Hz, direct-fit frequencies [2.09, 9.99, 22.17] Hz and `a` = [0.982, 0.990, 0.950]. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SOMATA is a python package built for state space modeling with Matsuda & Komaki oscillators and autoregressive models, made by the Purdon Lab at Stanford University. This PR is for a claude-implemented port of somata to pure Julia, as an opt-in submodule of
StateSpaceDynamics. SOMATA carries its own license, which is included in the source code and a notice of it is printed upon the first use of a somata class / function in a given Julia session (but can be hidden, see instructions in the documentation insrc/somata/Somata.jl).The key features are:
AbstractLinearGaussianStateModel <: AbstractStateModelto specify linear gaussian in function dispatchSomata.OscillatorStateModel <: AbstractLinearGaussianStateModelSomata.AutoRegressiveStateModel <: AbstractLinearGaussianStateModelSomata.CompositeStateModel <: AbstractLinearGaussianStateModelSomata.dosc"Decomposed Oscillator Search", a principled algorithm for learning the number of oscillations from data, rather than prespecifying a numberThis package allows for faster inference on these subclasses of models, with a significant speedup (2-30x, greater for smaller dimensional state spaces) over the python package. I used these models a ton in my work in an anesthesia EEG lab