def covariance_game(nums_actions, rho, random_state=None):
 N = len(nums_actions)
 if (N <= 1):
  raise ValueError('length of nums_actions must be at least 2')
 if (not (((-1) / (N - 1)) <= rho <= 1)):
  lb = ('-1' if (N == 2) else '-1/{0}'.format((N - 1)))
  raise ValueError('rho must be in [{0}, 1]'.format(lb))
 mean = np.zeros(N)
 cov = np.empty((N, N))
 cov.fill(rho)
 cov[(range(N), range(N))] = 1
 random_state = check_random_state(random_state)
 payoff_profile_array = random_state.multivariate_normal(mean, cov, nums_actions)
 g = NormalFormGame(payoff_profile_array)
 return g

def covariance_game ( nums_actions , rho , random_state = None ) : N = len ( nums_actions ) if ( N <= 1 ) : raise ValueError ( 'length of nums_actions must be at least 2' ) if ( not ( ( ( - 1 ) / ( N - 1 ) ) <= rho <= 1 ) ) : lb = ( '-1' if ( N == 2 ) else '-1/{0}' . format ( ( N - 1 ) ) ) raise ValueError ( 'rho must be in [{0}, 1]' . format ( lb ) ) mean = np . zeros ( N ) cov = np . empty ( ( N , N ) ) cov . fill ( rho ) cov [ ( range ( N ) , range ( N ) ) ] = 1 random_state = check_random_state ( random_state ) payoff_profile_array = random_state . multivariate_normal ( mean , cov , nums_actions ) g = NormalFormGame ( payoff_profile_array ) return g
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 .