Function Repository Resource:

BanzhafPowerIndex

Compute the strength of a voter by reference to the frequency with which their vote could change the outcome of an election

Contributed by: Seth J. Chandler
 ResourceFunction["BanzhafPowerIndex"][list] computes the power index where the votes of each player are denoted by list. ResourceFunction["BanzhafPowerIndex"][assoc] computes the power index where the keys of assoc are the identities of the players and the values of assoc are their respective number of votes. ResourceFunction["BanzhafPowerIndex"][votes,q] computes the power index, if q is the number of votes needed to win.

Details and Options

ResourceFunction["BanzhafPowerIndex"][votes,q,All] (or ResourceFunction["BanzhafPowerIndex"][votes,All]) returns an Association with two keys, "Index" and "Quota", where the "Index" key corresponds to the result of ResourceFunction["BanzhafPowerIndex"][votes,q] (or ResourceFunction["BanzhafPowerIndex"][votes]), while the "Quota" key corresponds to the number of votes needed to win.
ResourceFunction["BanzhafPowerIndex"] takes the following options:
 "TieResult" "Loss" how ties are treated "WinningFraction" fraction of players needed to have a winning number of votes
It is assumed by default that winning requires a majority of the votes cast. To change the fraction used to compute whether a set of players have a winning number of votes, set the "WinningFraction" option to a value between 0 and 1.
A tie is regarded as a loss by default. To let a tie be regarded as a win, set the value of the "TieResult"option to "Win".

Examples

Basic Examples (2)

Compute the Banzhaf power index where player 1 has 1 vote, player 2 has 2 votes and player 3 has 3 votes:

 In[1]:=
 Out[1]=

Compute the Banzhaf power index where you have not "named" the players:

 In[2]:=
 Out[2]=

Compute the Banzhaf power index for five players, assuming 11 votes are needed to win:

 In[3]:=
 Out[3]=

Scope (5)

Use All to obtain an Association containing information on the power index and the number of votes needed to win (the "quota"):

 In[4]:=
 Out[4]=

The additional All argument can be used even if the user explicitly sets the quota size:

 In[5]:=
 Out[5]=

The additional All argument can be used where the votes are structured as an Association between player name and vote:

 In[6]:=
 Out[6]=

BanzhafPowerIndex can handle a 100 player scenario in about one second on a typical 2022 laptop:

 In[7]:=
 Out[7]=

Going to a 200-player scenario increases the computation time by a factor of ≈ 6:

 In[8]:=
 Out[8]=

Compute the Banzhaf power index for votes amongst US states with different voting powers:

 In[9]:=
 Out[9]=
 In[10]:=
 Out[10]=

Reproduce the result from the original Banzhaf paper, suggesting that three communities effectively had no power:

 In[11]:=
 Out[11]=

Reproduce the result from the paper by Bilbao, Fernandez and Jiménez Losada:

 In[12]:=
 In[13]:=
 Out[13]=
 In[14]:=
 Out[14]=

Options (2)

TieResult (1)

Compare the results of whether a tie should be treated as a loss or win:

 In[15]:=
 Out[15]=
 In[16]:=
 Out[16]=

WinningFraction (1)

Find the Banzhaf power index assuming 2/3 of the votes are needed to win:

 In[17]:=
 Out[17]=

Applications (3)

Show how the power of each player changes as the quota needed to win changes:

 In[18]:=
 Out[18]=

Compute the power of each state in the United States electoral college assuming that electors from each state vote as a block:

 In[19]:=
 In[20]:=
 Out[20]=

Assume that the allocation of electors in most states is considered known but the allocation of electors in Florida, Pennsylvania, Ohio, North Carolina, and Wisconsin are considered "in play." Of the 92 electoral votes those states have, a candidate needs 58 of them to win. Compute the Banzhaf power index of the remaining five states:

 In[21]:=
 Out[21]=

The other candidate needs 34 votes to win. Compute the Banzhaf power index of the remaining five states:

 In[22]:=
 Out[22]=

See how the power distribution changes as we alter the winning fraction:

 In[23]:=
 In[24]:=
 Out[24]=

An alternative view:

 In[25]:=
 Out[25]=

Neat Examples (2)

This example explores how coalition formation affects the Banzhaf power index. The idea is to let individuals form coalitions which pledge themselves to aggregate the votes of the members and vote as a block in a certain way. One then computes the Banzhaf power index of the coalitions. Each coalition then distributes its power equally over its members. Start by taking 5 people with different numbers of votes:

 In[26]:=
 Out[26]=

Compute the Banzhaf power index of the members:

 In[27]:=
 Out[27]=

Take every set partition of the voters with the idea being that every grouping represents a coalition of voters. In the first example, everyone is in a single coalition. In the second example, a stands by itself and everyone else is in a coalition. In the third example, {a,b} is one coalition and {c,d,e} is the other. And so on for the 52 possible set partitions. (The number of partitions is equal to BellB[Length[s]]):

 In[28]:=
 Out[28]=

Compute the total vote of each coalition:

 In[29]:=
 Out[29]=

Associate each coalition with its total number of votes:

 In[30]:=
 Out[30]=

Compute the Banzhaf power index of each coalition (given the other coalitions):

 In[31]:=
 Out[31]=

Distribute the power of the coalitions equally over each of its members such that we end up with an Association between partitions of the sets of players and the power of each player after equal distribution:

 In[32]:=

Show which set partitions give player “a" the most power:

 In[33]:=
 Out[33]=

Take 30,000 voters in a business entity, each with a different number of votes with the distribution of votes determined by a Pareto distribution. Bin the voters and compute each bin's power index:

 In[34]:=

Show the distribution of voting power:

 In[35]:=
 Out[35]=

Bin the voters into 10 groups ("deciles") each with the same number of voters:

 In[36]:=
 Out[36]=

Get the total number of votes in each decile:

 In[37]:=
 Out[37]=

Get the ranges of votes within each decile:

 In[38]:=
 Out[38]=

Find the Banzhaf power index of each decile:

 In[39]:=
 Out[39]=

Change the rules so that each voter received the square root of the number of votes that they possess:

 In[40]:=
 Out[41]=

Seth J. Chandler

Version History

• 1.0.0 – 19 August 2022