Skip to content

tucoopy.solutions.banzhaf

Banzhaf values for TU games.

This module provides the (raw) Banzhaf value and common variants as semivalues.

banzhaf_value

banzhaf_value(game)

Compute the (raw) Banzhaf value for a TU game.

The Banzhaf value measures how often a player is critical across all coalitions, treating all coalitions of the other players as equally likely.

For player \(i\):

\[ \beta_i = \frac{1}{2^{n-1}} \sum_{S \subseteq N \setminus \{i\}} \big( v(S \cup \{i\}) - v(S) \big). \]

Parameters:

Name Type Description Default
game GameProtocol

TU game.

required

Returns:

Type Description
list[float]

Banzhaf value vector of length n_players.

Notes
  • This is the raw Banzhaf value (not normalized across players).
  • It is a semivalue corresponding to uniform weights over coalition sizes.
  • Often used in voting power analysis and simple games.

Examples:

>>> beta = banzhaf_value(g)
>>> len(beta) == g.n_players
True

normalized_banzhaf_value

normalized_banzhaf_value(game)

Compute the normalized Banzhaf value for a TU game.

The raw Banzhaf values are rescaled so that the resulting allocation sums to the value of the grand coalition:

\[ \hat{\beta}_i = \frac{\beta_i}{\sum_j \beta_j} \, v(N). \]

Parameters:

Name Type Description Default
game GameProtocol

TU game.

required

Returns:

Type Description
list[float]

Normalized Banzhaf allocation.

Notes
  • If all raw Banzhaf values are zero, the function returns a zero vector.
  • This normalization makes the Banzhaf value comparable to other allocation rules such as the Shapley value.

Examples:

>>> nb = normalized_banzhaf_value(g)
>>> sum(nb) == g.value(g.grand_coalition)
True

weighted_banzhaf_value

weighted_banzhaf_value(game, *, p=0.5)

Weighted Banzhaf value (p-binomial semivalue).

Interprets the marginal contribution as an expectation where each other player joins independently with probability p.

For p=0.5 this equals the (raw) Banzhaf value.

Parameters:

Name Type Description Default
game GameProtocol

TU game.

required
p float

Inclusion probability in [0, 1].

0.5

Returns:

Type Description
list[float]

Allocation vector of length n_players.

Raises:

Type Description
InvalidParameterError

If p is outside [0, 1].