本文整理汇总了Python中pyds.MassFunction.combine_conjunctive方法的典型用法代码示例。如果您正苦于以下问题:Python MassFunction.combine_conjunctive方法的具体用法?Python MassFunction.combine_conjunctive怎么用?Python MassFunction.combine_conjunctive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyds.MassFunction
的用法示例。
在下文中一共展示了MassFunction.combine_conjunctive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from pyds import MassFunction [as 别名]
# 或者: from pyds.MassFunction import combine_conjunctive [as 别名]
print('bel_1({a, b}) =', m1.bel({'a', 'b'}))
print('pl_1({a, b}) =', m1.pl({'a', 'b'}))
print('q_1({a, b}) =', m1.q({'a', 'b'}))
print('bel_1 =', m1.bel()) # entire belief function
print('bel_3 =', m3.bel())
print('m_3 from bel_3 =', MassFunction.from_bel(m3.bel())) # construct a mass function from a belief function
print('\n=== frame of discernment, focal sets, and core ===')
print('frame of discernment of m_1 =', m1.frame())
print('focal sets of m_1 =', m1.focal())
print('core of m_1 =', m1.core())
print('combined core of m_1 and m_3 =', m1.core(m3))
print('\n=== Dempster\'s combination rule, unnormalized conjunctive combination (exact and approximate) ===')
print('Dempster\'s combination rule for m_1 and m_2 =', m1 & m2)
print('Dempster\'s combination rule for m_1 and m_2 (Monte-Carlo, importance sampling) =', m1.combine_conjunctive(m2, sample_count=1000, importance_sampling=True))
print('Dempster\'s combination rule for m_1, m_2, and m_3 =', m1.combine_conjunctive(m2, m3))
print('unnormalized conjunctive combination of m_1 and m_2 =', m1.combine_conjunctive(m2, normalization=False))
print('unnormalized conjunctive combination of m_1 and m_2 (Monte-Carlo) =', m1.combine_conjunctive(m2, normalization=False, sample_count=1000))
print('unnormalized conjunctive combination of m_1, m_2, and m_3 =', m1.combine_conjunctive(m2, m3, normalization=False))
print('\n=== normalized and unnormalized conditioning ===')
print('normalized conditioning of m_1 with {a, b} =', m1.condition({'a', 'b'}))
print('unnormalized conditioning of m_1 with {b, c} =', m1.condition({'b', 'c'}, normalization=False))
print('\n=== disjunctive combination rule (exact and approximate) ===')
print('disjunctive combination of m_1 and m_2 =', m1 | m2)
print('disjunctive combination of m_1 and m_2 (Monte-Carlo) =', m1.combine_disjunctive(m2, sample_count=1000))
print('disjunctive combination of m_1, m_2, and m_3 =', m1.combine_disjunctive(m2, m3))
print('\n=== weight of conflict ===')
示例2: PyDSTest
# 需要导入模块: from pyds import MassFunction [as 别名]
# 或者: from pyds.MassFunction import combine_conjunctive [as 别名]
#.........这里部分代码省略.........
self.assertEqual(0.3, self.m3.q('ac'))
# compute the entire commonality function
q2 = self.m2.q()
self.assertEqual(8, len(q2))
for h, v in q2.items():
self.assertEqual(self.m2.q(h), v)
q3 = self.m3.q()
self.assertEqual(8, len(q3))
for h, v in q3.items():
self.assertEqual(self.m3.q(h), v)
def test_from_q(self):
self._assert_equal_belief(self.m1, MassFunction.from_q(self.m1.q()), 8)
self._assert_equal_belief(self.m2, MassFunction.from_q(self.m2.q()), 8)
self._assert_equal_belief(self.m3, MassFunction.from_q(self.m3.q()), 8)
def test_condition(self):
m1 = self.m1.condition('ad')
self.assertEqual(0.5, m1['a'])
self.assertEqual(0.5, m1['ad'])
m1_un = self.m1.condition('ad', normalization=False)
self.assertEqual(0.2, m1_un[''])
self.assertEqual(0.4, m1_un['a'])
self.assertEqual(0.4, m1_un['ad'])
m3 = self.m3.condition('ac')
self.assertEqual(0.5, m3['ac'])
self.assertAlmostEqual(1.0 / 3.0, m3['c'])
self.assertAlmostEqual(1.0 / 6.0, m3['a'])
m3_un = self.m3.condition('ab', normalization=False)
self.assertAlmostEqual(0.6, m3_un[set()])
self.assertEqual(0.3, m3_un['a'])
self.assertEqual(0.1, m3_un['ab'])
def test_combine_conjunctive(self):
def test(m, empty_mass, places=10):
self.assertAlmostEqual(empty_mass, m[set()], places)
norm = 0.55 + empty_mass
self.assertAlmostEqual(0.15 / norm, m['a'], places)
self.assertAlmostEqual(0.25 / norm, m['b'], places)
self.assertAlmostEqual(0.06 / norm, m['c'], places)
self.assertAlmostEqual(0.09 / norm, m['ac'], places)
# normalized
test(self.m1 & self.m2, 0.0)
test(self.m1.combine_conjunctive(self.m2, sample_count=10000), 0.0, 1)
test(self.m1.combine_conjunctive(self.m2, sample_count=1000, importance_sampling=True), 0.0)
# unnormalized
test(self.m1.combine_conjunctive(self.m2, normalization=False), 0.45)
test(self.m1.combine_conjunctive(self.m2, normalization=False, sample_count=10000), 0.45, 2)
test(self.m1.combine_conjunctive(self.m2, normalization=False, sample_count=1000, importance_sampling=True), 0.45, 2) # ImpSam should be ignored
# combine multiple mass functions
m_single = self.m1.combine_conjunctive(self.m1).combine_conjunctive(self.m2)
m_multi = self.m1.combine_conjunctive(self.m1, self.m2)
self._assert_equal_belief(m_single, m_multi, 10)
# combine incompatible mass function
self.assertFalse(self.m1 & MassFunction({(0, 1):0.8, (0,):0.2}))
def test_combine_disjunctive(self):
def test(m, places):
self.assertAlmostEqual(0.2, m['ab'], places)
self.assertAlmostEqual(0.2, m['ac'], places)
self.assertAlmostEqual(0.1, m['b'], places)
self.assertAlmostEqual(0.04, m['bc'], places)
self.assertAlmostEqual(0.06, m['abc'], places)
self.assertAlmostEqual(0.05, m['abd'], places)
self.assertAlmostEqual(0.05, m['acd'], places)
self.assertAlmostEqual(0.3, m['abcd'], places)
示例3: PyDSTest
# 需要导入模块: from pyds import MassFunction [as 别名]
# 或者: from pyds.MassFunction import combine_conjunctive [as 别名]
#.........这里部分代码省略.........
self.assertEqual(0.3, self.m3.q('ac'))
# compute the entire commonality function
q2 = self.m2.q()
self.assertEqual(8, len(q2))
for h, v in q2.items():
self.assertEqual(self.m2.q(h), v)
q3 = self.m3.q()
self.assertEqual(8, len(q3))
for h, v in q3.items():
self.assertEqual(self.m3.q(h), v)
def test_from_q(self):
self._assert_equal_belief(self.m1, MassFunction.from_q(self.m1.q()), 8)
self._assert_equal_belief(self.m2, MassFunction.from_q(self.m2.q()), 8)
self._assert_equal_belief(self.m3, MassFunction.from_q(self.m3.q()), 8)
def test_condition(self):
m1 = self.m1.condition('ad')
self.assertEqual(0.5, m1['a'])
self.assertEqual(0.5, m1['ad'])
m1_un = self.m1.condition('ad', normalization=False)
self.assertEqual(0.2, m1_un[''])
self.assertEqual(0.4, m1_un['a'])
self.assertEqual(0.4, m1_un['ad'])
m3 = self.m3.condition('ac')
self.assertEqual(0.5, m3['ac'])
self.assertAlmostEqual(1.0 / 3.0, m3['c'])
self.assertAlmostEqual(1.0 / 6.0, m3['a'])
m3_un = self.m3.condition('ab', normalization=False)
self.assertAlmostEqual(0.6, m3_un[set()])
self.assertEqual(0.3, m3_un['a'])
self.assertEqual(0.1, m3_un['ab'])
def test_combine_conjunctive(self):
def test(m, empty_mass, places=10):
self.assertAlmostEqual(empty_mass, m[set()], places)
norm = 0.55 + empty_mass
self.assertAlmostEqual(0.15 / norm, m['a'], places)
self.assertAlmostEqual(0.25 / norm, m['b'], places)
self.assertAlmostEqual(0.06 / norm, m['c'], places)
self.assertAlmostEqual(0.09 / norm, m['ac'], places)
# normalized
test(self.m1 & self.m2, 0.0)
test(self.m1.combine_conjunctive(self.m2, sample_count=10000), 0.0, 1)
test(self.m1.combine_conjunctive(self.m2, sample_count=1000, importance_sampling=True), 0.0)
# unnormalized
test(self.m1.combine_conjunctive(self.m2, normalization=False), 0.45)
test(self.m1.combine_conjunctive(self.m2, normalization=False, sample_count=10000), 0.45, 2)
test(self.m1.combine_conjunctive(self.m2, normalization=False, sample_count=1000, importance_sampling=True), 0.45, 2) # ImpSam should be ignored
# combine multiple mass functions
m_single = self.m1.combine_conjunctive(self.m1).combine_conjunctive(self.m2)
m_multi = self.m1.combine_conjunctive(self.m1, self.m2)
self._assert_equal_belief(m_single, m_multi, 10)
# combine incompatible mass function
self.assertFalse(self.m1 & MassFunction({(0, 1):0.8, (0,):0.2}))
def test_combine_disjunctive(self):
def test(m, places):
self.assertAlmostEqual(0.2, m['ab'], places)
self.assertAlmostEqual(0.2, m['ac'], places)
self.assertAlmostEqual(0.1, m['b'], places)
self.assertAlmostEqual(0.04, m['bc'], places)
self.assertAlmostEqual(0.06, m['abc'], places)
self.assertAlmostEqual(0.05, m['abd'], places)
self.assertAlmostEqual(0.05, m['acd'], places)
self.assertAlmostEqual(0.3, m['abcd'], places)