osl_dynamics.simulation.HierarchicalHMM#
- class osl_dynamics.simulation.HierarchicalHMM(top_level_trans_prob, bottom_level_trans_probs, n_states=None, top_level_stay_prob=None, bottom_level_stay_probs=None, top_level_hmm_type='hmm', top_level_gamma_shape=None, top_level_gamma_scale=None)#
Two-level hierarchical HMM.
A top-level HMM (or HSMM) selects which bottom-level HMM generates the state at each time point. The bottom-level HMMs share the same states and only differ in their transition probability matrix.
- Parameters:
- top_level_trans_probnp.ndarray or str
Transition probability matrix of the top-level HMM. Used when
top_level_hmm_type='hmm'.- bottom_level_trans_probslist of np.ndarray or str
Transition probability matrices for the bottom-level HMMs.
- n_statesint, optional
Number of states.
- top_level_stay_probfloat, optional
The
stay_probfor the top-level HMM. Used iftop_level_trans_probis astr.- bottom_level_stay_probslist of float, optional
The
stay_probfor each bottom-level HMM. Used when the corresponding entry inbottom_level_trans_probsis astr.- top_level_hmm_typestr, optional
Either
'hmm'or'hsmm'.- top_level_gamma_shapefloat, optional
Shape parameter for the Gamma distribution of the top-level state lifetimes when
top_level_hmm_type='hsmm'.- top_level_gamma_scalefloat, optional
Scale parameter for the Gamma distribution of the top-level state lifetimes when
top_level_hmm_type='hsmm'.
- n_bottom_level_hmms#
- bottom_level_hmms#
- n_states#
- generate_states(n_samples)#
Generate a state time course.
The top-level state time course is stored in
top_level_stc.- Parameters:
- n_samplesint
Number of samples.
- Returns:
- state_time_coursenp.ndarray
One-hot state time course. Shape is (n_samples, n_states).