public class InfoTheory
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
base_log
Base when computing the logarithms.
|
Constructor and Description |
---|
InfoTheory() |
Modifier and Type | Method and Description |
---|---|
static double |
log(double x,
int base)
Calculates the logarithm of input x w.r.t any base.
|
static double |
log2(double x)
Calculates the logarithm of input x w.r.t base 2.
|
static double |
log2Multi(double x,
double y)
Calculates the logarithm of input x w.r.t base 2,
multiplied by y, where 0 log 0 = 0.
|
static double |
logMulti(double x,
int base,
double y)
Calculates the logarithm of input x w.r.t any base,
multiplied by y, where 0 log 0 = 0.
|
static double |
mean(double[] Data)
This method returns the mean of given data.
|
static double |
median(double[] Data)
This method returns the median of given data.
|
static double[] |
outputDist(double[] inputDist,
double[][] matrix)
Calculate the marginal output probability distribution
P_Y from a given input distribution inputDist and
a given channel matrix matrix.
|
static double |
outputProb(int outputIndex,
double[] Q,
double[][] W)
Finds the change of output elementIndex
using P_Y(y) = R(y) = QW(y) = Σ_x W(y|x)Q(x).
|
static void |
printPMF(double[] probs)
Prints the probability distribution probs with
where element a_i has prob[i], to 4 decimal places.
|
static void |
printPMF(java.lang.String[] names,
double[] probs)
Prints the probability distribution probs with
where element names[i] has prob[i].
|
static double[] |
uniformDist(int noOfElements)
Calculates the uniform distribution of length "noOfElements".
|
public static final int base_log
public static double log(double x, int base)
x
- the real number whose logarithm is calculated.base
- The base w.r.t. which logarithm is calculated.public static double log2(double x)
x
- the real number whose logarithm is calculated.public static double log2Multi(double x, double y)
x
- the real number whose logarithm is calculated.y
- the real number that multiplies log_2 xpublic static double logMulti(double x, int base, double y)
x
- the real number whose logarithm is calculated.base
- the base w.r.t. which logarithm is calculated.y
- the real number that multiplies log_{base} xpublic static double mean(double[] Data)
Data
- data arraypublic static double median(double[] Data)
Data
- data arraypublic static double[] outputDist(double[] inputDist, double[][] matrix)
inputDist
- input distribution arraymatrix
- channel matrix arraypublic static double outputProb(int outputIndex, double[] Q, double[][] W)
outputIndex
- output index of the channel matrix WQ
- input PMF arrayW
- channel matrixpublic static void printPMF(double[] probs)
probs
- array of PMFpublic static void printPMF(java.lang.String[] names, double[] probs)
names
- array of labelsprobs
- array of PMFpublic static double[] uniformDist(int noOfElements)
noOfElements
- the number of elements in the uniform distribution.