|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--mark.core.math.Table
Assume a sampling process, where each sample determines two discrete random variables, X1 and X2. The range of Xi is the integers in [0, l(Xi) - 1], where l(Xi) is the number of values Xi can assume. A Table maintains joint counts of X1 and X2. Counts may be doubles, meaning that a count of 0.5, for example, is legal.
| Constructor Summary | |
Table(double[][] a)
Initializes all counts with the values in the given array. |
|
Table(int X1Length,
int X2Length)
Initializes all counts to zero. |
|
Table(int X1Length,
int X2Length,
boolean laplace)
Initializes all counts to zero if not laplace and to one if laplace. |
|
Table(int X1Length,
int X2Length,
double lidstoneLambda)
Initializes all counts to zero if not laplace and to one if laplace. |
|
| Method Summary | |
int[] |
argmax()
Returns the (X1, X2) value of the largest count in the table. |
int[] |
argmin()
Returns the (X1, X2) value of the smallest count in the table. |
double |
chiSquared()
Returns the chi-squared value of the given table. |
java.lang.Object |
clone()
Clones the Table. |
boolean |
equals(java.lang.Object rhs)
Returns whether the Table is equivalent to the given Table. |
void |
inc(int x1,
int x2)
Increments #(X1 = x1, X2 = x2). |
void |
inc(int x1,
int x2,
double c)
Increments #(X1 = x1, X2 = x2) by the given count. |
static void |
main(java.lang.String[] a)
Tests the class. |
double |
max()
Returns the largest count in the table. |
double |
min()
Returns the smallest count in the table. |
double |
mutualInformation()
Returns the mutual information of (X1, X2): I(X1;X2). |
void |
normalizeCounts()
Divides each count by the sum of the counts. |
double |
num()
Returns the total number of samples. |
double |
numX1(int x1)
Returns #(X1 = x1). |
double |
numX1X2(int x1,
int x2)
Returns #(X1 = x1, X2 = x2). |
double |
numX2(int x2)
Returns #(X2 = x2). |
Table |
pointwiseChiSquared()
Returns a table that contains the pointwise chi squared values of each each (X1, X2) value. |
double |
pointwiseChiSquared(int x1,
int x2)
Returns the pointwise chi-squared value of (X1, X2). |
double |
prob()
Returns 1.0. |
double |
probX1(int x1)
Returns p(X1 = x1). |
double |
probX1X2(int x1,
int x2)
Returns p(X1 = x1, X2 = x2). |
double |
probX2(int x2)
Returns p(X2 = x2). |
void |
reset(boolean laplace)
Resets all counts to zero if not laplace and to one if laplace. |
void |
reset(double lidstoneLambda)
Resets all counts to lidStoneLambda, and that times the vector lengths. |
void |
set(int x1,
int x2,
double c)
Sets #(X1 = x1, X2 = x2). |
double[][] |
toDoubleArray()
Returns a representation as a double[][]. |
java.lang.String |
toSSString()
Returns a string representation of the table, suitable for entry into a spreadsheet. |
java.lang.String |
toSSStringWithSums()
Returns a string representation of the table and its sums, suitable for entry into a spreadsheet. |
java.lang.String |
toSSStringWithSums(java.lang.String[] X1Names,
java.lang.String[] X2Names)
Returns a string representation of the table and its sums, along with a header row and column, suitable for entry into a spreadsheet. |
java.lang.String |
toString()
Returns a string representation of the table. |
Table |
weightedPointwiseMutualInformation()
Returns a table that contains the weighted pointwise mutual information of each (X1, X2) value. |
double |
weightedPointwiseMutualInformation(int x1,
int x2)
Returns the weighted pointwise mutual information of (X1, X2). |
double[] |
X1Counts(int x1)
Returns a double array that indicates, for the given x1, and for each x2 in the range of X2, #(X1 = x1, X2 = x2). |
int |
X1Length()
Returns the number of values X1 can assume. |
double[] |
X2Counts(int x2)
Returns a double array that indicates, for the given x2, and for each x1 in the range of X1, #(X1, X2). |
int |
X2Length()
Returns the number of values X2 can assume. |
| Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Table(int X1Length,
int X2Length)
X1Length - l(X1), the number of values X1 can assume.X2Length - l(X2), the number of values X2 can assume.
public Table(int X1Length,
int X2Length,
boolean laplace)
X1Length - the number values X1 can assume.X2Length - the number values X2 can assume.laplace - whether to use laplace smoothing.
public Table(int X1Length,
int X2Length,
double lidstoneLambda)
X1Length - the number values X1 can assume.X2Length - the number values X2 can assume.lidstoneLambda - the quantity of phantom counts to add in smoothingpublic Table(double[][] a)
a - the array.| Method Detail |
public java.lang.Object clone()
clone in class java.lang.Objectpublic boolean equals(java.lang.Object rhs)
equals in class java.lang.Objectrhs - the given Table.
public java.lang.String toString()
toString in class java.lang.Objectpublic double[][] toDoubleArray()
public void reset(boolean laplace)
laplace - whether to use laplace smoothing.public void reset(double lidstoneLambda)
lidstoneLambda - the number of phantom counts per cell to addpublic int X1Length()
public int X2Length()
public double numX1X2(int x1,
int x2)
x1 - the X1 value.x2 - the X2 value.
public double numX1(int x1)
x1 - the X1 value.
public double numX2(int x2)
x2 - the X2 value.
public double num()
public double probX1X2(int x1,
int x2)
x1 - the X1 value.x2 - the X2 value.
public double probX1(int x1)
x1 - the X1 value.
public double probX2(int x2)
x2 - the X2 value.
public double prob()
public void set(int x1,
int x2,
double c)
x1 - the X1 value.x2 - the X2 value.c - the count.
public void inc(int x1,
int x2)
x1 - the X1 value.x2 - the X2 value.
public void inc(int x1,
int x2,
double c)
x1 - the X1 value.x2 - the X2 value.c - the count.public void normalizeCounts()
public static void main(java.lang.String[] a)
throws java.lang.Exception
a - ignored.
java.lang.Exceptionpublic double max()
public double min()
public int[] argmax()
public int[] argmin()
public double[] X1Counts(int x1)
x1 - the X1 value.
public double[] X2Counts(int x2)
x2 - the X2 value.
public double chiSquared()
public Table pointwiseChiSquared()
public double pointwiseChiSquared(int x1,
int x2)
x1 - the X1 value.x2 - the X2 value.
public double mutualInformation()
public Table weightedPointwiseMutualInformation()
public double weightedPointwiseMutualInformation(int x1,
int x2)
x1 - the X1 value.x2 - the X2 value.
public java.lang.String toSSString()
public java.lang.String toSSStringWithSums()
public java.lang.String toSSStringWithSums(java.lang.String[] X1Names,
java.lang.String[] X2Names)
throws java.lang.Exception
X1Names - defines the X1 titles.X2Names - defines the X2 titles.
java.lang.Exception - if something goes wrong.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||