model
leaguedata.model
DTMCModel
Class used to define a Discrete Time Markov Chain for modelling game history.
Source code in leaguedata/model.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
ref_table
property
Mapping between binary and categorical representation of states.
uniform_prior
property
Define a uniform prior over the states.
RETURNS | DESCRIPTION |
---|---|
jnp.array: The uniform prior. |
__init__(n)
Build a Discrete Markov Chain model.
PARAMETER | DESCRIPTION |
---|---|
n
|
The number of game in memory. If n = 0, the model is a Bernoulli process.
TYPE:
|
binary_serie_to_categorical(serie)
Convert a binary representation of states to a categorical representation.
PARAMETER | DESCRIPTION |
---|---|
serie
|
The binary serie to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
np.array: The categorical serie. |
Source code in leaguedata/model.py
build_process(steps, probs=None)
Build a Markov Chain process with the given number of steps.
PARAMETER | DESCRIPTION |
---|---|
steps
|
The number of steps of the process.
TYPE:
|
probs
|
The probabilities of winning at each state.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tfd.MarkovChain: The Markov Chain process. |
Source code in leaguedata/model.py
build_transition_matrix(probs)
Build the transition matrix of the model.
PARAMETER | DESCRIPTION |
---|---|
probs
|
The probabilities of winning at each state.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
jnp.array: The transition matrix. |
Source code in leaguedata/model.py
categorical_serie_to_binary(serie)
Convert a categorical representation of states to a binary representation.
PARAMETER | DESCRIPTION |
---|---|
serie
|
The categorical serie to convert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
np.array: The binary serie. |
Source code in leaguedata/model.py
get_states()
Get all the states of the model, which are the combinations of n binary values.
RETURNS | DESCRIPTION |
---|---|
list
|
The list of all states. |
Source code in leaguedata/model.py
stationary_distribution(probs)
Compute the stationary distribution of the model.
PARAMETER | DESCRIPTION |
---|---|
probs
|
The probabilities of winning at each state.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
jnp.array: The stationary distribution. |
Source code in leaguedata/model.py
to_mermaid(probs)
Convert the model to a Mermaid graph.
PARAMETER | DESCRIPTION |
---|---|
probs
|
The probabilities of winning at each state.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The Mermaid graph. |
Source code in leaguedata/model.py
generate_coinflip_history(number_of_games=85, number_of_players=200, key=PRNGKey(42))
Generate mock history of players using the coinflip model.
PARAMETER | DESCRIPTION |
---|---|
number_of_games
|
The number of games in the mock history.
TYPE:
|
number_of_players
|
The number of players.
TYPE:
|
key
|
The key to generate the mock history.
TYPE:
|
Source code in leaguedata/model.py
generate_nasty_loser_q(number_of_games=85, number_of_players=200, key=PRNGKey(42), return_importance=False)
Generate mock history of players using the nasty loserQ model.
PARAMETER | DESCRIPTION |
---|---|
number_of_games
|
The number of games in the mock history.
TYPE:
|
number_of_players
|
The number of players.
TYPE:
|
key
|
The key to generate the mock history.
TYPE:
|
return_importance
|
Whether to return the importance of the loserQ for each player.
TYPE:
|
Source code in leaguedata/model.py
generate_obvious_loser_q(number_of_games=85, number_of_players=200, key=PRNGKey(42))
Generate mock history of players using the obvious loserQ model.
PARAMETER | DESCRIPTION |
---|---|
number_of_games
|
The number of games in the mock history.
TYPE:
|
number_of_players
|
The number of players.
TYPE:
|
key
|
The key to generate the mock history.
TYPE:
|