Skip to content

API reference

Everything below is importable from the top-level package, for example statespacecheck.event_diagnostics.

Per-spike diagnostics

The paper's method: HPD overlap, KL divergence and the rank-based predictive p-value for every spike, thresholds from a baseline period, and flagging.

Continuous marks

The per-spike diagnostics, with the predictive p-value by Monte Carlo, for marks that cannot be enumerated, such as the waveform features of clusterless decoding.

Comparing distributions

HPD overlap and KL divergence between a state distribution and a likelihood, for each row; used per spike by event_diagnostics and clusterless_event_diagnostics, or per time bin with a whole-bin likelihood (an extension beyond the paper).

  • hpd_overlap: Compute overlap between HPD regions of state distribution and likelihood.
  • kl_divergence: Compute Kullback-Leibler divergence between state distribution and likelihood.

Highest-density regions

The regions HPD overlap compares.

Predictive densities and Monte Carlo checks

An extension beyond the paper: predictive densities of whole time bins and a Monte Carlo predictive p-value with a user-supplied sampler.

Flagging time series

An extension beyond the paper: flagging runs of time bins and aggregating over periods. For per-spike values use flag_events.

Plotting

An extension beyond the paper: time-series plots of the diagnostics.

  • plot_diagnostics: Plot HPD overlap, KL divergence (with its robust z-score), and p-values.

Types and constants

  • DistributionArray: the type of the float64 arrays the functions return, numpy.typing.NDArray[numpy.float64]. Inputs may be any array-like.
  • DEFAULT_COVERAGE: the default coverage of HPD regions, 0.95, as in the paper.
  • LogMarkIntensity and MarkSampler: the types of the model functions a MarkModel holds.