mirror of https://github.com/jlizier/jidt
Made comments in headers for Python simple functions more python like (referring to numpy arrays etc)
This commit is contained in:
parent
6b2cf5c69c
commit
1db1c3ac8c
|
|
@ -206,7 +206,7 @@
|
|||
"Computes the Shannon entropy for a probability distribution p.\n",
|
||||
"\n",
|
||||
"Inputs:\n",
|
||||
"- p - (array which much sum to 1) - a probability distribution to compute the Shannon info content for\n",
|
||||
"- p - (numpy array or list which much sum to 1) - a probability distribution to compute the Shannon info content for\n",
|
||||
"\n",
|
||||
"Outputs:\n",
|
||||
"- result - Shannon entropy of the probability distribution p\n",
|
||||
|
|
|
|||
|
|
@ -74,13 +74,13 @@
|
|||
"X from samples x_n.\n",
|
||||
"\n",
|
||||
"Inputs:\n",
|
||||
"- xn - samples of outcomes x.\n",
|
||||
" xn is a column vector, e.g. xn = [0;0;1;0;1;0;1;1;1;0] for a binary variable.\n",
|
||||
"- xn - samples of outcomes x as a numpy array or a list,\n",
|
||||
" e.g. xn = [0,0,1,0,1,0,1,1,1,0] for a binary variable.\n",
|
||||
"\n",
|
||||
"Outputs:\n",
|
||||
"- result - Shannon entropy over all outcomes\n",
|
||||
"- symbols - list of unique samples\n",
|
||||
"- probabilities - probabilities for each sample\n",
|
||||
"- symbols - numpy array of unique samples\n",
|
||||
"- probabilities - numpy array of probabilities for each sample\n",
|
||||
"\n",
|
||||
"Copyright (C) 2020-, Julio Correa, Joseph T. Lizier\n",
|
||||
"Distributed under GNU General Public License v3\n",
|
||||
|
|
@ -199,10 +199,11 @@
|
|||
"\n",
|
||||
"Inputs:\n",
|
||||
"- p - probability distribution function over all outcome vectors x.\n",
|
||||
" p is a matrix over all combinations of the sub-variables of x,\n",
|
||||
"where p(1,3) gives the probability of the first symbol of sub-variable\n",
|
||||
" p is a numpy matrix (or list of lists) over all combinations of the sub-variables of x,\n",
|
||||
"where p[0,2] gives the probability of the first symbol of sub-variable\n",
|
||||
"x1 co-occuring with the third symbol of sub-variable x2.\n",
|
||||
" E.g. p = [0.2, 0.3; 0.1, 0.4]. The sum over p must be 1.\n",
|
||||
" E.g. p = np.array([[0.2, 0.3], [0.1, 0.4]])\n",
|
||||
" The sum over p must be 1.\n",
|
||||
"\n",
|
||||
"Outputs:\n",
|
||||
"- result - joint Shannon entropy of the probability distribution p\n",
|
||||
|
|
@ -275,7 +276,7 @@
|
|||
"if they don't wish to join them outside of the call.\n",
|
||||
"\n",
|
||||
"Inputs:\n",
|
||||
"- xn - matrix of samples of outcomes x. May be a 1D vector of samples\n",
|
||||
"- xn - numpy matrix (or list of lists) of samples of outcomes x. May be a 1D vector of samples\n",
|
||||
" (in which case yn is also supplied), or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate X\n",
|
||||
" (in which case yn is not supplied).\n",
|
||||
|
|
@ -284,8 +285,8 @@
|
|||
"\n",
|
||||
"Outputs:\n",
|
||||
"- result - joint Shannon entropy over all samples\n",
|
||||
"- symbols - list of unique joint vector samples\n",
|
||||
"- probabilities - probabilities for each joint symbol\n",
|
||||
"- symbols - numpy array of unique joint vector samples\n",
|
||||
"- probabilities - numpy array of probabilities for each joint symbol\n",
|
||||
"\n",
|
||||
"Copyright (C) 2020-, Julio Correa, Joseph T. Lizier\n",
|
||||
"Distributed under GNU General Public License v3\n",
|
||||
|
|
@ -377,10 +378,11 @@
|
|||
"\n",
|
||||
"Inputs:\n",
|
||||
"- p - 2D probability distribution function over all outcomes (x,y).\n",
|
||||
" p is a matrix over all combinations of x and y,\n",
|
||||
"where p(1,3) gives the probability of the first symbol of variable\n",
|
||||
" p is a numpy matrix over all combinations of x and y,\n",
|
||||
"where p[0, 2] gives the probability of the first symbol of variable\n",
|
||||
"x co-occuring with the third symbol of variable y.\n",
|
||||
" E.g. p = [0.2, 0.3; 0.1, 0.4]. The sum over p must be 1.\n",
|
||||
" E.g. p = nump.array([[0.2, 0.3], [0.1, 0.4]]).\n",
|
||||
" The sum over p must be 1.\n",
|
||||
"\n",
|
||||
"Outputs:\n",
|
||||
"- result - conditional Shannon entropy of X given Y\n",
|
||||
|
|
@ -476,9 +478,9 @@
|
|||
"variable X, given samples yn of a random variable Y.\n",
|
||||
"\n",
|
||||
"Inputs:\n",
|
||||
"- xn - matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
"- xn - numpy matrix (or list of lists) of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate X.\n",
|
||||
"- yn - matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
"- yn - numpy matrix (or list of lists) of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate Y.\n",
|
||||
" Must have the same number of rows as X.\n",
|
||||
"\n",
|
||||
|
|
|
|||
|
|
@ -100,10 +100,11 @@
|
|||
"\n",
|
||||
"Inputs:\n",
|
||||
"- p - 2D probability distribution function over all outcomes (x,y).\n",
|
||||
" p is a matrix over all combinations of x and y,\n",
|
||||
"where p(1,3) gives the probability of the first symbol of variable\n",
|
||||
" p is a numpy matrix (or list of lists) over all combinations of x and y,\n",
|
||||
"where p[0,2] gives the probability of the first symbol of variable\n",
|
||||
"x co-occuring with the third symbol of variable y.\n",
|
||||
" E.g. p = [0.2, 0.3; 0.1, 0.4]. The sum over p must be 1.\n",
|
||||
" E.g. p = np.array([[0.2, 0.3], [0.1, 0.4]]).\n",
|
||||
" The sum over p must be 1.\n",
|
||||
"\n",
|
||||
"Outputs:\n",
|
||||
"- result - mutual information of X with Y\n",
|
||||
|
|
@ -210,9 +211,9 @@
|
|||
"variable X with samples yn of a random variable Y.\n",
|
||||
"\n",
|
||||
"Inputs:\n",
|
||||
"- xn - matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
"- xn - numpy matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate X.\n",
|
||||
"- yn - matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
"- yn - numpy matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate Y.\n",
|
||||
" Must have the same number of rows as X.\n",
|
||||
"\n",
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@
|
|||
"samples zn of a random variable Z.\n",
|
||||
"\n",
|
||||
"Inputs:\n",
|
||||
"- xn - matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
"- xn - numpy matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate X.\n",
|
||||
"- yn - matrix of samples of outcomes y. May be a 1D vector of samples, or\n",
|
||||
"- yn - numpy matrix of samples of outcomes y. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate Y.\n",
|
||||
" Must have the same number of rows as X.\n",
|
||||
"- zn - matrix of samples of outcomes z. May be a 1D vector of samples, or\n",
|
||||
"- zn - numpy matrix of samples of outcomes z. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate Z\n",
|
||||
" which will be conditioned on.\n",
|
||||
" Must have the same number of rows as X.\n",
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@
|
|||
"Computes the Shannon entropy for a probability distribution p.\n",
|
||||
"\n",
|
||||
"Inputs:\n",
|
||||
"- p - (array which much sum to 1) - a probability distribution to compute the Shannon info content for\n",
|
||||
"- p - (numpy array or list which much sum to 1) - a probability distribution to compute the Shannon info content for\n",
|
||||
"\n",
|
||||
"Outputs:\n",
|
||||
"- result - Shannon entropy of the probability distribution p\n",
|
||||
|
|
@ -303,9 +303,9 @@
|
|||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/tmp/ipykernel_617811/3406804068.py:20: RuntimeWarning: divide by zero encountered in log2\n",
|
||||
"/tmp/ipykernel_1348680/3406804068.py:20: RuntimeWarning: divide by zero encountered in log2\n",
|
||||
" return -np.log2(p)\n",
|
||||
"/tmp/ipykernel_617811/1887577405.py:28: RuntimeWarning: invalid value encountered in multiply\n",
|
||||
"/tmp/ipykernel_1348680/253220426.py:28: RuntimeWarning: invalid value encountered in multiply\n",
|
||||
" weightedShannonInfos = p*(infocontent(p))\n"
|
||||
]
|
||||
}
|
||||
|
|
@ -349,9 +349,9 @@
|
|||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/tmp/ipykernel_617811/3406804068.py:20: RuntimeWarning: divide by zero encountered in log2\n",
|
||||
"/tmp/ipykernel_1348680/3406804068.py:20: RuntimeWarning: divide by zero encountered in log2\n",
|
||||
" return -np.log2(p)\n",
|
||||
"/tmp/ipykernel_617811/1887577405.py:28: RuntimeWarning: invalid value encountered in multiply\n",
|
||||
"/tmp/ipykernel_1348680/253220426.py:28: RuntimeWarning: invalid value encountered in multiply\n",
|
||||
" weightedShannonInfos = p*(infocontent(p))\n"
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -74,13 +74,13 @@
|
|||
"X from samples x_n.\n",
|
||||
"\n",
|
||||
"Inputs:\n",
|
||||
"- xn - samples of outcomes x.\n",
|
||||
" xn is a column vector, e.g. xn = [0;0;1;0;1;0;1;1;1;0] for a binary variable.\n",
|
||||
"- xn - samples of outcomes x as a numpy array or a list,\n",
|
||||
" e.g. xn = [0,0,1,0,1,0,1,1,1,0] for a binary variable.\n",
|
||||
"\n",
|
||||
"Outputs:\n",
|
||||
"- result - Shannon entropy over all outcomes\n",
|
||||
"- symbols - list of unique samples\n",
|
||||
"- probabilities - probabilities for each sample\n",
|
||||
"- symbols - numpy array of unique samples\n",
|
||||
"- probabilities - numpy array of probabilities for each sample\n",
|
||||
"\n",
|
||||
"Copyright (C) 2020-, Julio Correa, Joseph T. Lizier\n",
|
||||
"Distributed under GNU General Public License v3\n",
|
||||
|
|
@ -136,8 +136,7 @@
|
|||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1.0\n",
|
||||
"2.0\n"
|
||||
"1.0\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -146,8 +145,7 @@
|
|||
"(result, symbols, probabilities) = entropyempirical([0,0,1,1])\n",
|
||||
"print( result )\n",
|
||||
"# Other cases:\n",
|
||||
"(result, symbols, probabilities) = entropyempirical([0,0,1,1,2,2,3,3])\n",
|
||||
"print( result )\n"
|
||||
"(result, symbols, probabilities) = entropyempirical([0,0,1,1,2,2,3,3])\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -192,9 +190,9 @@
|
|||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1.0\n",
|
||||
"0.9987271686073539\n",
|
||||
"1.9969914126082884\n"
|
||||
"0.9709505944546686\n",
|
||||
"0.9999884584088952\n",
|
||||
"1.999117638235098\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -244,10 +242,11 @@
|
|||
"\n",
|
||||
"Inputs:\n",
|
||||
"- p - probability distribution function over all outcome vectors x.\n",
|
||||
" p is a matrix over all combinations of the sub-variables of x,\n",
|
||||
"where p(1,3) gives the probability of the first symbol of sub-variable\n",
|
||||
" p is a numpy matrix (or list of lists) over all combinations of the sub-variables of x,\n",
|
||||
"where p[0,2] gives the probability of the first symbol of sub-variable\n",
|
||||
"x1 co-occuring with the third symbol of sub-variable x2.\n",
|
||||
" E.g. p = [0.2, 0.3; 0.1, 0.4]. The sum over p must be 1.\n",
|
||||
" E.g. p = np.array([[0.2, 0.3], [0.1, 0.4]])\n",
|
||||
" The sum over p must be 1.\n",
|
||||
"\n",
|
||||
"Outputs:\n",
|
||||
"- result - joint Shannon entropy of the probability distribution p\n",
|
||||
|
|
@ -294,9 +293,9 @@
|
|||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/home/joseph/Dropbox/Work/Teaching/USyd/CSYS5030-InfoTheoryAndSelfOrg/Lectures/Module1-Entropy/PythonCode/completed/simpleinfotheory.py:23: RuntimeWarning: divide by zero encountered in log2\n",
|
||||
"/home/joseph/JIDT/course/course/Module01-Entropy/PythonSimpleFunctions/completed/simpleinfotheory.py:23: RuntimeWarning: divide by zero encountered in log2\n",
|
||||
" return -np.log2(p)\n",
|
||||
"/home/joseph/Dropbox/Work/Teaching/USyd/CSYS5030-InfoTheoryAndSelfOrg/Lectures/Module1-Entropy/PythonCode/completed/simpleinfotheory.py:48: RuntimeWarning: invalid value encountered in multiply\n",
|
||||
"/home/joseph/JIDT/course/course/Module01-Entropy/PythonSimpleFunctions/completed/simpleinfotheory.py:52: RuntimeWarning: invalid value encountered in multiply\n",
|
||||
" weightedShannonInfos = p*(infocontent(p))\n"
|
||||
]
|
||||
}
|
||||
|
|
@ -342,7 +341,7 @@
|
|||
"if they don't wish to join them outside of the call.\n",
|
||||
"\n",
|
||||
"Inputs:\n",
|
||||
"- xn - matrix of samples of outcomes x. May be a 1D vector of samples\n",
|
||||
"- xn - numpy matrix (or list of lists) of samples of outcomes x. May be a 1D vector of samples\n",
|
||||
" (in which case yn is also supplied), or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate X\n",
|
||||
" (in which case yn is not supplied).\n",
|
||||
|
|
@ -351,8 +350,8 @@
|
|||
"\n",
|
||||
"Outputs:\n",
|
||||
"- result - joint Shannon entropy over all samples\n",
|
||||
"- symbols - list of unique joint vector samples\n",
|
||||
"- probabilities - probabilities for each joint symbol\n",
|
||||
"- symbols - numpy array of unique joint vector samples\n",
|
||||
"- probabilities - numpy array of probabilities for each joint symbol\n",
|
||||
"\n",
|
||||
"Copyright (C) 2020-, Julio Correa, Joseph T. Lizier\n",
|
||||
"Distributed under GNU General Public License v3\n",
|
||||
|
|
@ -407,7 +406,7 @@
|
|||
"text": [
|
||||
"2.0\n",
|
||||
"1.0\n",
|
||||
"2.997035867545411\n"
|
||||
"2.996212691342311\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -459,10 +458,11 @@
|
|||
"\n",
|
||||
"Inputs:\n",
|
||||
"- p - 2D probability distribution function over all outcomes (x,y).\n",
|
||||
" p is a matrix over all combinations of x and y,\n",
|
||||
"where p(1,3) gives the probability of the first symbol of variable\n",
|
||||
" p is a numpy matrix over all combinations of x and y,\n",
|
||||
"where p[0, 2] gives the probability of the first symbol of variable\n",
|
||||
"x co-occuring with the third symbol of variable y.\n",
|
||||
" E.g. p = [0.2, 0.3; 0.1, 0.4]. The sum over p must be 1.\n",
|
||||
" E.g. p = nump.array([[0.2, 0.3], [0.1, 0.4]]).\n",
|
||||
" The sum over p must be 1.\n",
|
||||
"\n",
|
||||
"Outputs:\n",
|
||||
"- result - conditional Shannon entropy of X given Y\n",
|
||||
|
|
@ -582,9 +582,9 @@
|
|||
"variable X, given samples yn of a random variable Y.\n",
|
||||
"\n",
|
||||
"Inputs:\n",
|
||||
"- xn - matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
"- xn - numpy matrix (or list of lists) of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate X.\n",
|
||||
"- yn - matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
"- yn - numpy matrix (or list of lists) of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate Y.\n",
|
||||
" Must have the same number of rows as X.\n",
|
||||
"\n",
|
||||
|
|
|
|||
|
|
@ -100,10 +100,11 @@
|
|||
"\n",
|
||||
"Inputs:\n",
|
||||
"- p - 2D probability distribution function over all outcomes (x,y).\n",
|
||||
" p is a matrix over all combinations of x and y,\n",
|
||||
"where p(1,3) gives the probability of the first symbol of variable\n",
|
||||
" p is a numpy matrix (or list of lists) over all combinations of x and y,\n",
|
||||
"where p[0,2] gives the probability of the first symbol of variable\n",
|
||||
"x co-occuring with the third symbol of variable y.\n",
|
||||
" E.g. p = [0.2, 0.3; 0.1, 0.4]. The sum over p must be 1.\n",
|
||||
" E.g. p = np.array([[0.2, 0.3], [0.1, 0.4]]).\n",
|
||||
" The sum over p must be 1.\n",
|
||||
"\n",
|
||||
"Outputs:\n",
|
||||
"- result - mutual information of X with Y\n",
|
||||
|
|
@ -172,9 +173,9 @@
|
|||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/home/joseph/Dropbox/Work/Teaching/USyd/CSYS5030-InfoTheoryAndSelfOrg/Lectures/Module1-Entropy/PythonCode/completed/simpleinfotheory.py:23: RuntimeWarning: divide by zero encountered in log2\n",
|
||||
"/home/joseph/JIDT/course/course/Module01-Entropy/PythonSimpleFunctions/completed/simpleinfotheory.py:23: RuntimeWarning: divide by zero encountered in log2\n",
|
||||
" return -np.log2(p)\n",
|
||||
"/home/joseph/Dropbox/Work/Teaching/USyd/CSYS5030-InfoTheoryAndSelfOrg/Lectures/Module1-Entropy/PythonCode/completed/simpleinfotheory.py:48: RuntimeWarning: invalid value encountered in multiply\n",
|
||||
"/home/joseph/JIDT/course/course/Module01-Entropy/PythonSimpleFunctions/completed/simpleinfotheory.py:52: RuntimeWarning: invalid value encountered in multiply\n",
|
||||
" weightedShannonInfos = p*(infocontent(p))\n"
|
||||
]
|
||||
}
|
||||
|
|
@ -255,9 +256,9 @@
|
|||
"variable X with samples yn of a random variable Y.\n",
|
||||
"\n",
|
||||
"Inputs:\n",
|
||||
"- xn - matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
"- xn - numpy matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate X.\n",
|
||||
"- yn - matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
"- yn - numpy matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate Y.\n",
|
||||
" Must have the same number of rows as X.\n",
|
||||
"\n",
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@
|
|||
"samples zn of a random variable Z.\n",
|
||||
"\n",
|
||||
"Inputs:\n",
|
||||
"- xn - matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
"- xn - numpy matrix of samples of outcomes x. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate X.\n",
|
||||
"- yn - matrix of samples of outcomes y. May be a 1D vector of samples, or\n",
|
||||
"- yn - numpy matrix of samples of outcomes y. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate Y.\n",
|
||||
" Must have the same number of rows as X.\n",
|
||||
"- zn - matrix of samples of outcomes z. May be a 1D vector of samples, or\n",
|
||||
"- zn - numpy matrix of samples of outcomes z. May be a 1D vector of samples, or\n",
|
||||
" a 2D matrix, where each row is a vector sample for a multivariate Z\n",
|
||||
" which will be conditioned on.\n",
|
||||
" Must have the same number of rows as X.\n",
|
||||
|
|
@ -151,10 +151,10 @@
|
|||
"0.0\n",
|
||||
"1.0\n",
|
||||
"1.0\n",
|
||||
"I(X;Y) = 0.0004 bits\n",
|
||||
"I(Z;Y) = 0.0004 bits\n",
|
||||
"I(X;Y|Z) = 0.9995 bits\n",
|
||||
"I(Z;Y|X) = 0.9995 bits\n"
|
||||
"I(X;Y) = 0.0001 bits\n",
|
||||
"I(Z;Y) = 0.0013 bits\n",
|
||||
"I(X;Y|Z) = 0.9987 bits\n",
|
||||
"I(Z;Y|X) = 0.9998 bits\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ def infocontent(p):
|
|||
Computes the Shannon entropy for a probability distribution p.
|
||||
|
||||
Inputs:
|
||||
- p - (array which much sum to 1) - a probability distribution to compute the Shannon info content for
|
||||
- p - (numpy array or list which much sum to 1) - a probability distribution to compute the Shannon info content for
|
||||
|
||||
Outputs:
|
||||
- result - Shannon entropy of the probability distribution p
|
||||
|
|
@ -62,13 +62,13 @@ Computes the Shannon entropy over all outcomes x of a random variable
|
|||
X from samples x_n.
|
||||
|
||||
Inputs:
|
||||
- xn - samples of outcomes x.
|
||||
xn is a column vector, e.g. xn = [0;0;1;0;1;0;1;1;1;0] for a binary variable.
|
||||
- xn - samples of outcomes x as a numpy array or a list,
|
||||
e.g. xn = [0,0,1,0,1,0,1,1,1,0] for a binary variable.
|
||||
|
||||
Outputs:
|
||||
- result - Shannon entropy over all outcomes
|
||||
- symbols - list of unique samples
|
||||
- probabilities - probabilities for each sample
|
||||
- symbols - numpy array of unique samples
|
||||
- probabilities - numpy array of probabilities for each sample
|
||||
|
||||
Copyright (C) 2020-, Julio Correa, Joseph T. Lizier
|
||||
Distributed under GNU General Public License v3
|
||||
|
|
@ -116,10 +116,11 @@ vector x.
|
|||
|
||||
Inputs:
|
||||
- p - probability distribution function over all outcome vectors x.
|
||||
p is a matrix over all combinations of the sub-variables of x,
|
||||
where p(1,3) gives the probability of the first symbol of sub-variable
|
||||
p is a numpy matrix (or list of lists) over all combinations of the sub-variables of x,
|
||||
where p[0,2] gives the probability of the first symbol of sub-variable
|
||||
x1 co-occuring with the third symbol of sub-variable x2.
|
||||
E.g. p = [0.2, 0.3; 0.1, 0.4]. The sum over p must be 1.
|
||||
E.g. p = np.array([[0.2, 0.3], [0.1, 0.4]])
|
||||
The sum over p must be 1.
|
||||
|
||||
Outputs:
|
||||
- result - joint Shannon entropy of the probability distribution p
|
||||
|
|
@ -146,7 +147,7 @@ variable X from sample vectors x_n. User can call with two such arguments
|
|||
if they don't wish to join them outside of the call.
|
||||
|
||||
Inputs:
|
||||
- xn - matrix of samples of outcomes x. May be a 1D vector of samples
|
||||
- xn - numpy matrix (or list of lists) of samples of outcomes x. May be a 1D vector of samples
|
||||
(in which case yn is also supplied), or
|
||||
a 2D matrix, where each row is a vector sample for a multivariate X
|
||||
(in which case yn is not supplied).
|
||||
|
|
@ -155,8 +156,8 @@ Inputs:
|
|||
|
||||
Outputs:
|
||||
- result - joint Shannon entropy over all samples
|
||||
- symbols - list of unique joint vector samples
|
||||
- probabilities - probabilities for each joint symbol
|
||||
- symbols - numpy array of unique joint vector samples
|
||||
- probabilities - numpy array of probabilities for each joint symbol
|
||||
|
||||
Copyright (C) 2020-, Julio Correa, Joseph T. Lizier
|
||||
Distributed under GNU General Public License v3
|
||||
|
|
@ -201,10 +202,11 @@ Probability matrix p(x,y) is given for each candidate outcome
|
|||
|
||||
Inputs:
|
||||
- p - 2D probability distribution function over all outcomes (x,y).
|
||||
p is a matrix over all combinations of x and y,
|
||||
where p(1,3) gives the probability of the first symbol of variable
|
||||
p is a numpy matrix over all combinations of x and y,
|
||||
where p[0, 2] gives the probability of the first symbol of variable
|
||||
x co-occuring with the third symbol of variable y.
|
||||
E.g. p = [0.2, 0.3; 0.1, 0.4]. The sum over p must be 1.
|
||||
E.g. p = nump.array([[0.2, 0.3], [0.1, 0.4]]).
|
||||
The sum over p must be 1.
|
||||
|
||||
Outputs:
|
||||
- result - conditional Shannon entropy of X given Y
|
||||
|
|
@ -241,9 +243,9 @@ Computes the conditional Shannon entropy over all samples xn of a random
|
|||
variable X, given samples yn of a random variable Y.
|
||||
|
||||
Inputs:
|
||||
- xn - matrix of samples of outcomes x. May be a 1D vector of samples, or
|
||||
- xn - numpy matrix (or list of lists) of samples of outcomes x. May be a 1D vector of samples, or
|
||||
a 2D matrix, where each row is a vector sample for a multivariate X.
|
||||
- yn - matrix of samples of outcomes x. May be a 1D vector of samples, or
|
||||
- yn - numpy matrix (or list of lists) of samples of outcomes x. May be a 1D vector of samples, or
|
||||
a 2D matrix, where each row is a vector sample for a multivariate Y.
|
||||
Must have the same number of rows as X.
|
||||
|
||||
|
|
@ -291,10 +293,11 @@ Probability matrix p(x,y) is given for each candidate outcome
|
|||
|
||||
Inputs:
|
||||
- p - 2D probability distribution function over all outcomes (x,y).
|
||||
p is a matrix over all combinations of x and y,
|
||||
where p(1,3) gives the probability of the first symbol of variable
|
||||
p is a numpy matrix (or list of lists) over all combinations of x and y,
|
||||
where p[0,2] gives the probability of the first symbol of variable
|
||||
x co-occuring with the third symbol of variable y.
|
||||
E.g. p = [0.2, 0.3; 0.1, 0.4]. The sum over p must be 1.
|
||||
E.g. p = np.array([[0.2, 0.3], [0.1, 0.4]]).
|
||||
The sum over p must be 1.
|
||||
|
||||
Outputs:
|
||||
- result - mutual information of X with Y
|
||||
|
|
@ -338,13 +341,13 @@ Computes the mutual information over all samples xn of a random
|
|||
variable X with samples yn of a random variable Y.
|
||||
|
||||
Inputs:
|
||||
- xn - matrix of samples of outcomes x. May be a 1D vector of samples, or
|
||||
- xn - numpy matrix of samples of outcomes x. May be a 1D vector of samples, or
|
||||
a 2D matrix, where each row is a vector sample for a multivariate X.
|
||||
- yn - matrix of samples of outcomes x. May be a 1D vector of samples, or
|
||||
- yn - numpy matrix of samples of outcomes x. May be a 1D vector of samples, or
|
||||
a 2D matrix, where each row is a vector sample for a multivariate Y.
|
||||
Must have the same number of rows as X.
|
||||
|
||||
Outputs:
|
||||
Outputs: (There are additional outputs here in comparison to the solution notebook)
|
||||
- result - mutual information of X with Y
|
||||
- xySymbols - list of unique joint vector samples
|
||||
- xyProbs - probabilities for each joint symbol
|
||||
|
|
@ -463,12 +466,12 @@ variable X with samples yn of a random variable Y, conditioning on
|
|||
samples zn of a random variable Z.
|
||||
|
||||
Inputs:
|
||||
- xn - matrix of samples of outcomes x. May be a 1D vector of samples, or
|
||||
- xn - numpy matrix of samples of outcomes x. May be a 1D vector of samples, or
|
||||
a 2D matrix, where each row is a vector sample for a multivariate X.
|
||||
- yn - matrix of samples of outcomes y. May be a 1D vector of samples, or
|
||||
- yn - numpy matrix of samples of outcomes y. May be a 1D vector of samples, or
|
||||
a 2D matrix, where each row is a vector sample for a multivariate Y.
|
||||
Must have the same number of rows as X.
|
||||
- zn - matrix of samples of outcomes z. May be a 1D vector of samples, or
|
||||
- zn - numpy matrix of samples of outcomes z. May be a 1D vector of samples, or
|
||||
a 2D matrix, where each row is a vector sample for a multivariate Z
|
||||
which will be conditioned on.
|
||||
Must have the same number of rows as X.
|
||||
|
|
|
|||
Loading…
Reference in New Issue