<commit_before>from __future__ import division
import sys
import argparse
from random import uniform
import numpy as np
from scipy.stats import binom
import unittest
from mc_tools import mc_compute_stationary


# Default values
default_N, default_epsilon = 27, 1e-2
default_p = 1/3  # action 1 is risk-dominant

# Tolerance level
default_TOL = 1e-2


def KMR_Markov_matrix_simultaneous(N, p, epsilon):
    """
    Generate the Markov matrix for the KMR model with *simultaneous* move

    N: number of players
    p: level of p-dominance for action 1
       = the value of p such that action 1 is the BR for (1-q, q) for any q > p,
         where q (1-q, resp.) is the prob that the oppenent plays action 1 (0, resp.)
    epsilon: mutation probability
    """
    P = np.empty((N+1, N+1), dtype=float)
    for n in range(N+1):
        P[n, :] = \
            (n/N < p) * binom.pmf(range(N+1), N, epsilon/2) + \
            (n/N == p) * binom.pmf(range(N+1), N, 1/2) + \
            (n/N > p) * binom.pmf(range(N+1), N, 1-epsilon/2)
    return P


def KMR_Markov_matrix_sequential(N, p, epsilon):
    """
    Generate the Markov matrix for the KMR model with *sequential* move

    N: number of players
    p: level of p-dominance for action 1
       = the value of p such that action 1 is the BR for (1-q, q) for any q > p,
         where q (1-q, resp.) is the prob that the oppenent plays action 1 (0, resp.)
    epsilon: mutation probability
    """
    P = np.zeros((N+1, N+1), dtype=float)
    P[0, 0], P[0, 1] = 1 - epsilon * (1/2), epsilon * (1/2)
    for n in range(1, N):
        P[n, n-1] = \
            (n/N) * (epsilon * (1/2) +
                     (1 - epsilon) * (((n-1)/(N-1) < p) + ((n-1)/(N-1) == p) * (1/2))
                     )<commit_msg>Typos corrected<commit_after>from __future__ import division
import sys
import argparse
from random import uniform
import numpy as np
from scipy.stats import binom
import unittest
from mc_tools import mc_compute_stationary


# Default values
default_N, default_epsilon = 27, 1e-2
default_p = 1/3  # action 1 is risk-dominant

# Tolerance level
default_TOL = 1e-2


def KMR_Markov_matrix_simultaneous(N, p, epsilon):
    """
    Generate the Markov matrix for the KMR model with *simultaneous* move

    N: number of players
    p: level of p-dominance for action 1
       = the value of p such that action 1 is the BR for (1-q, q) for any q > p,
         where q (1-q, resp.) is the prob that the opponent plays action 1 (0, resp.)
    epsilon: mutation probability
    """
    P = np.empty((N+1, N+1), dtype=float)
    for n in range(N+1):
        P[n, :] = \
            (n/N < p) * binom.pmf(range(N+1), N, epsilon/2) + \
            (n/N == p) * binom.pmf(range(N+1), N, 1/2) + \
            (n/N > p) * binom.pmf(range(N+1), N, 1-epsilon/2)
    return P


def KMR_Markov_matrix_sequential(N, p, epsilon):
    """
    Generate the Markov matrix for the KMR model with *sequential* move

    N: number of players
    p: level of p-dominance for action 1
       = the value of p such that action 1 is the BR for (1-q, q) for any q > p,
         where q (1-q, resp.) is the prob that the opponent plays action 1 (0, resp.)
    epsilon: mutation probability
    """
    P = np.zeros((N+1, N+1), dtype=float)
    P[0, 0], P[0, 1] = 1 - epsilon * (1/2), epsilon * (1/2)
    for n in range(1, N):
        P[n, n-1] = \
            (n/N) * (epsilon * (1/2) +
                     (1 - epsilon) * (((n-1)/(N-1) < p) + ((n-1)/(N-1) == p) * (1/2))
                     )
{'fraction_non_alphanumeric': 0.1322360953461975, 'fraction_numerical': 0.03064699205448354, 'mean_word_length': 2.31296992481203, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5033452', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1271, 'n_words': 445}