Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168695
Image: ubuntu2004

Aufgabe 1: Banzhaf-Index

from itertools import imap
def banzhaf(quotum, weight, other_weights): return sum(1 for s in imap(sum, powerset(other_weights)) if s < quotum and quotum <= s + weight)

Absoluter Banzhaf-Index

def abs_banzhafs(quotum, *weights): return vector(banzhaf(quotum, w, weights[:i]+weights[i+1:]) for i, w in enumerate(weights))

Relativer Banzhaf-Index

def rel_banzhafs(quotum, *weights): abs_indices = abs_banzhafs(quotum, *weights) return abs_indices / sum(abs_indices)

Bundestag

bt_stimmgewichte = (239, 146, 93, 76, 68)
abs_banzhafs(312, *bt_stimmgewichte)
(12, 4, 4, 4, 0)
abs_banzhafs(415, *bt_stimmgewichte)
(8, 6, 2, 2, 2)

Norderweiterung

eu_stimmgewichte_v, qv = (4, 4, 4, 0, 2, 2, 0, 0, 1), 10 eu_stimmgewichte_n, qn = (10, 10, 10, 10, 5, 5, 3, 3, 2), 41
rel_banzhafs(qv, *eu_stimmgewichte_v)
(7/27, 7/27, 7/27, 0, 1/9, 1/9, 0, 0, 0)
rel_banzhafs(qn, *eu_stimmgewichte_n)
(53/317, 53/317, 53/317, 53/317, 29/317, 29/317, 21/317, 21/317, 5/317)