📚 Math in Society
⇩ Download ▾

3.4 Calculating Power- Banzhaf Power Index

The Banzhaf power index was originally created in 1946 by Lionel Penrose, but was reintroduced by John Banzhaf in 1965. The power index is a numerical way of looking at power in a weighted voting situation.

# Math in Society 3.4 -- Banzhaf Power Index, coalition by coalition
# List every winning coalition, star the critical players, count the stars.
from itertools import combinations

def banzhaf(q, w, names=None, show=True):
    n = len(w)
    names = names or [f"P{i+1}" for i in range(n)]
    counts = [0] * n
    rows = []
    for k in range(1, n + 1):
        for c in combinations(range(n), k):
            weight = sum(w[i] for i in c)
            if weight < q:
                continue
            crit = {i for i in c if weight - w[i] < q}
            for i in crit:
                counts[i] += 1
            rows.append((c, crit, weight))
    grand = sum(counts)
    print(f"[{q}: {', '.join(map(str, w))}]   {len(rows)} winning coalitions"
          f"   ({grand} critical slots in total)")
    if show:
        for c, crit, weight in rows:
            body = ", ".join(f"*{names[i]}*" if i in crit else names[i] for i in c)
            print(f"   {{{body}}}   weight {weight}")
    for i in range(n):
        print(f"   {names[i]:<20} critical in {counts[i]:>3} of them"
              f"   ->  {counts[i]}/{grand} = {counts[i]/grand:6.1%}"
              + ("   (a dummy)" if counts[i] == 0 else ""))
    print()
    return counts

banzhaf(8, [6, 3, 2])
banzhaf(16, [7, 6, 3, 3, 2])
banzhaf(36, [20, 17, 16, 3])          # EDIT: change the quota or any weight
banzhaf(65, [47, 46, 17, 16, 2], show=False,
        names=["Scottish National", "Labour", "Conservative",
               "Liberal Democrat", "Green"])

print("The Liberal Democrats hold 16 seats and the Greens hold 2, yet their Banzhaf")
print("power is identical: in every coalition where one of them tips the balance,")
print("so does the other. Weight is not power.")
print("Try it: in [36: 20, 17, 16, 3] raise the quota to 41 and re-run. The")
print("3-weight player drops from 8.3% of the power to a dummy, while the other")
print("three all gain veto power -- one number moved, and the whole structure changed.")

The Banzhaf power index measures a player’s ability to influence the outcome of the vote. Notice that player 5 has a power index of 0, indicating that there is no coalition in which they would be critical power and could influence the outcome. This means player 5 is a dummy, as we noted earlier.

The weighted voting system that Americans are most familiar with is the Electoral College system used to elect the President. In the Electoral College, states are given a number of votes equal to the number of their congressional representatives (house + senate). Most states give all their electoral votes to the candidate that wins a majority in their state, turning the Electoral College into a weighted voting system, in which the states are the players. As I’m sure you can imagine, there are billions of possible winning coalitions, so the power index for the Electoral College has to be computed by a computer using approximation techniques.

Adapted from Math in Society by David Lippman, hosted on LibreTexts (math.libretexts.org) and licensed under CC BY-SA 3.0. Changes were made. License: CC-BY-SA-3.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or ADA Title II. Every page is built against an automated accessibility gate, and the published editions will meet ADA Title II requirements when they release in late September 2026. If something is unusable, please tell us.