public class GeneralBimatrixSolverTools
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static double[] |
constantDoubleArray(double constant,
int dimension)
Returns a double array of a given dimension filled with the same value.
|
static double |
dot(double[] a,
double[] b)
Returns the dot product of two vectors
|
static double[] |
expectedPayoffs(double[][] payoffRowPlayer,
double[][] payoffColPlayer,
double[][] jointActionProbabilities) |
static double[] |
expectedPayoffs(double[][] payoffRowPlayer,
double[][] payoffColPlayer,
double[] rowPlayerStrategy,
double[] colPlayerStrategy)
Computes the expected payoff for each player in a bimatrix game according to their strategies.
|
static double[] |
getNegatedArray(double[] a)
Returns a negated version of the input array in a new array object.
|
static double[][] |
getNegatedMatrix(double[][] m)
Returns a negated version of the input matrix in a new matrix object.
|
static double[][] |
getPositiveMatrix(double[][] m)
Creates a new matrix (m2) whose values are the values of m shifted by a constant amount c such that all the values
in m2 are positive.
|
static double[][] |
jointActionProbabilities(double[] rowPlayerStrategy,
double[] colPlayerStrategy)
Computes the joint action probabilities accroding to each player's strategy and returns it as a matrix.
|
static double[] |
marginalizeColPlayerStrategy(double[][] jointActionProbabilities)
Returns the column player's strategy by marginalizing it out from a joint action probability distribution represented as a matrix
|
static double[] |
marginalizeRowPlayerStrategy(double[][] jointActionProbabilities)
Returns the row player's strategy by marginalizing it out from a joint action probability distribution represented as a matrix
|
static double[][] |
transposeMatrix(double[][] m)
Creates and returns a new matrix that is a transpose of m.
|
static double[] |
zero1Array(int index,
int dim)
Creates an array that is all zeros except one index which has a value of 1.
|
public static double[] expectedPayoffs(double[][] payoffRowPlayer, double[][] payoffColPlayer, double[] rowPlayerStrategy, double[] colPlayerStrategy)
payoffRowPlayer
- the payoff for player 1. Rows are player 1's actions; columns player 2's.payoffColPlayer
- the payoff for player 2. Rows are player 1's actions; columns player 2's.rowPlayerStrategy
- the strategy for player 1. Should be array with dimension equal to the number of player 1's actions.colPlayerStrategy
- the stratgy for player 2. Should be array with dimension equal to the number of player 2's actions.public static double[] expectedPayoffs(double[][] payoffRowPlayer, double[][] payoffColPlayer, double[][] jointActionProbabilities)
public static double[][] jointActionProbabilities(double[] rowPlayerStrategy, double[] colPlayerStrategy)
rowPlayerStrategy
- the strategy of the player whose actions will be represented by the rows of the returned matrix.colPlayerStrategy
- the strategy of the player whose actions will represented by the columns of the returned matrix.public static double[] marginalizeRowPlayerStrategy(double[][] jointActionProbabilities)
jointActionProbabilities
- a matrix of 2-player joint aciton probability distributionpublic static double[] marginalizeColPlayerStrategy(double[][] jointActionProbabilities)
jointActionProbabilities
- a matrix of 2-player joint aciton probability distributionpublic static double[] constantDoubleArray(double constant, int dimension)
constant
- the constant value with which the double array is filled.dimension
- the dimension of the double array.public static double[][] getNegatedMatrix(double[][] m)
m
- the input matrix.public static double[] getNegatedArray(double[] a)
a
- the input double arraypublic static double[][] getPositiveMatrix(double[][] m)
m
- the input matrix.public static double[][] transposeMatrix(double[][] m)
m
- the input matrix.public static double dot(double[] a, double[] b)
a
- first vectorb
- second vectorpublic static double[] zero1Array(int index, int dim)
index
- the index which will have a valu of 1dim
- the dimension of the array to create