giddy.markov.kullback¶
- giddy.markov.kullback(F)[source]¶
Kullback information based test of Markov Homogeneity.
- Parameters:
- Farray
(s, r, r), values are transitions (not probabilities) for s strata, r initial states, r terminal states.
- Returns:
- Resultsdictionary
(key - value)
Conditional homogeneity - (float) test statistic for homogeneity of transition probabilities across strata.
Conditional homogeneity pvalue - (float) p-value for test statistic.
Conditional homogeneity dof - (int) degrees of freedom = r(s-1)(r-1).
Notes
Based on [KKK62]. Example below is taken from Table 9.2 .
Examples
>>> import numpy as np >>> from giddy.markov import kullback >>> s1 = np.array([ ... [ 22, 11, 24, 2, 2, 7], ... [ 5, 23, 15, 3, 42, 6], ... [ 4, 21, 190, 25, 20, 34], ... [0, 2, 14, 56, 14, 28], ... [32, 15, 20, 10, 56, 14], ... [5, 22, 31, 18, 13, 134] ... ]) >>> s2 = np.array([ ... [3, 6, 9, 3, 0, 8], ... [1, 9, 3, 12, 27, 5], ... [2, 9, 208, 32, 5, 18], ... [0, 14, 32, 108, 40, 40], ... [22, 14, 9, 26, 224, 14], ... [1, 5, 13, 53, 13, 116] ... ]) >>> >>> F = np.array([s1, s2]) >>> res = kullback(F) >>> "%8.3f"%res['Conditional homogeneity'] ' 160.961' >>> "%d"%res['Conditional homogeneity dof'] '30' >>> "%3.1f"%res['Conditional homogeneity pvalue'] '0.0'