def test_from_counts__2_vars__vars_as_arg(self): counts = Series({('a', 'b'): 1, ('c', 'd'): 2, ('e', 'f'): 3}) discrete = Discrete.from_counts(counts, variables=['ace', 'bdf']) self.assertEqual(['ace', 'bdf'], discrete.variables) self.assertEqual({ 'ace': ['a', 'c', 'e'], 'bdf': ['b', 'd', 'f'] }, discrete.states) self.assertEqual(1 / 6, discrete.p(ace='a', bdf='b')) self.assertEqual(2 / 6, discrete.p(ace='c', bdf='d')) self.assertEqual(3 / 6, discrete.p(ace='e', bdf='f'))
def test_mean_categorical(self): counts = Series({'a': 1, 'c': 2, 'e': 3}) discrete = Discrete.from_counts(counts, variables='x') self.assertRaises(TypeError, discrete.mean)
def test_mode_1d_multi_value(self): counts = Series({'a': 2, 'b': 2, 'c': 1}) discrete = Discrete.from_counts(counts, variables='x') self.assertListEqual(['a', 'b'], discrete.mode())
def test_mode_1d_categorical(self): counts = Series({'a': 1, 'c': 2, 'e': 3}) discrete = Discrete.from_counts(counts, variables='x') self.assertEqual('e', discrete.mode())