# random¶

Generate random NormalFormGame instances.

quantecon.game_theory.random.covariance_game(nums_actions, rho, random_state=None)[source]

Return a random NormalFormGame instance where the payoff profiles are drawn independently from the standard multi-normal with the covariance of any pair of payoffs equal to rho, as studied in [1].

Parameters:
nums_actionstuple(int)

Tuple of the numbers of actions, one for each player.

rhoscalar(float)

Covariance of a pair of payoff values. Must be in [-1/(N-1), 1], where N is the number of players.

random_stateint or np.random.RandomState/Generator, optional

Random seed (integer) or np.random.RandomState or Generator instance to set the initial state of the random number generator for reproducibility. If None, a randomly initialized RandomState is used.

Returns:
gNormalFormGame

References

[1]

Y. Rinott and M. Scarsini, “On the Number of Pure Strategy Nash Equilibria in Random Games,” Games and Economic Behavior (2000), 274-293.

Examples

```>>> rng = np.random.default_rng(12345)
>>> g = covariance_game((3, 2), rho=-0.7, random_state=rng)
>>> print(g)
2-player NormalFormGame with payoff profile array:
[[[ 1.80214175, -0.8232619 ],  [ 0.7023331 , -0.90308782]],
[[-0.2174803 , -0.35640649],  [ 1.51235766, -1.00972746]],
[[-1.08921974, -0.42346148],  [-1.78910753,  2.53930201]]]
```
quantecon.game_theory.random.random_game(nums_actions, random_state=None)[source]

Return a random NormalFormGame instance where the payoffs are drawn independently from the uniform distribution on [0, 1).

Parameters:
nums_actionstuple(int)

Tuple of the numbers of actions, one for each player.

random_stateint or np.random.RandomState/Generator, optional

Random seed (integer) or np.random.RandomState or Generator instance to set the initial state of the random number generator for reproducibility. If None, a randomly initialized RandomState is used.

Returns:
gNormalFormGame

Examples

```>>> rng = np.random.default_rng(12345)
>>> g = random_game((3, 2), random_state=rng)
>>> print(g)
2-player NormalFormGame with payoff profile array:
[[[0.22733602, 0.59830875],  [0.31675834, 0.94180287]],
[[0.79736546, 0.18673419],  [0.67625467, 0.24824571]],
[[0.39110955, 0.67275604],  [0.33281393, 0.94888115]]]
```
quantecon.game_theory.random.random_mixed_actions(nums_actions, random_state=None)[source]

Return a tuple of random mixed actions (vectors of floats).

Parameters:
nums_actionstuple(int)

Tuple of the numbers of actions, one for each player.

random_stateint or np.random.RandomState/Generator, optional

Random seed (integer) or np.random.RandomState or Generator instance to set the initial state of the random number generator for reproducibility. If None, a randomly initialized RandomState is used.

Returns:
action_profiletuple(ndarray(float, ndim=1))

Tuple of mixed_actions, one for each player.

quantecon.game_theory.random.random_pure_actions(nums_actions, random_state=None)[source]

Return a tuple of random pure actions (integers).

Parameters:
nums_actionstuple(int)

Tuple of the numbers of actions, one for each player.

random_stateint or np.random.RandomState/Generator, optional

Random seed (integer) or np.random.RandomState or Generator instance to set the initial state of the random number generator for reproducibility. If None, a randomly initialized RandomState is used.

Returns:
action_profileTuple(int)

Tuple of actions, one for each player.